A
A
Alexander2018-07-30 07:37:25
Django
Alexander, 2018-07-30 07:37:25

How to solve the Broken pipe problem?

I work with gmail api. The error occurs exactly in this place:

try:
            message = self.service.users().messages().send(userId='me', body=message).execute()
            print('Message Id: %s' % message['id'])
            return message
        except errors.HttpError as error:
            print('An error occurred: %s' % error)

error code:
Exception Type: BrokenPipeError at /ru/api/v1/my_url
Exception Value: [Errno 32] Broken pipe

As I understand it, the gmail api has a long response, and the server closes it and therefore the Broken pipe error pops up , maybe I'm wrong.
Traceback

BrokenPipeError at /ru/api/v1/my_url/
[Errno 32] Broken pipe
Request Method: POST
Request URL: https://apihrc.wienerdeming.com/ru/api/v1/my_url/
Django Version: 2.0
Python Executable: /my_project/.venv/bin/uwsgi
Python Version: 3.6.1
Python Path: ['.', '', '/my_project/.venv/lib64/python36.zip', '/my_project/.venv/lib64/python3.6', '/my_project/.venv/lib64/python3.6/lib-dynload', '/usr/lib64/python3.6', '/usr/lib/python3.6', '/my_project/.venv/lib/python3.6/site-packages', '/my_project', '/my_project/apps']
Server time: Пн, 30 Июл 2018 16:02:43 +0500
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'easy_thumbnails',
'django_filters',
'rest_framework',
'dynamic_rest',
'rest_framework.authtoken',
'easy_pdf',
'corsheaders',
'parler',
*'my_apps'
]
Installed Middleware:
['raven.contrib.django.middleware.SentryMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'system.utils.middleware.RequestLogsMiddleware']
Traceback:
File "/my_project/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/my_project/.venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/my_project/.venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
95. return self.dispatch(request, *args, **kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
494. response = self.handle_exception(exc)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
454. self.raise_uncaught_exception(exc)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
491. response = handler(request, *args, **kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/mixins.py" in create
21. self.perform_create(serializer)
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/mixins.py" in perform_create
26. serializer.save()
File "/my_project/.venv/lib/python3.6/site-packages/rest_framework/serializers.py" in save
214. self.instance = self.create(validated_data)
File "/usr/lib64/python3.6/contextlib.py" in inner
53. return func(*args, **kwds)
File "/my_project/apps/applications/serializers/application_action.py" in create
83. self._submit_to_client(application, validated_data.get('comment', ""))
File "/my_project/apps/applications/serializers/application_action.py" in _submit_to_client
113. send = gmail.messages.send_message(message=message)
File "/my_project/apps/mailboxes/utils/gmail/messages.py" in send_message
129. message = self.service.users().messages().send(userId='me', body=message).execute()
File "/my_project/.venv/lib/python3.6/site-packages/googleapiclient/_helpers.py" in positional_wrapper
130. return wrapped(*args, **kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/googleapiclient/http.py" in execute
835. method=str(self.method), body=self.body, headers=self.headers)
File "/my_project/.venv/lib/python3.6/site-packages/googleapiclient/http.py" in _retry_request
179. raise exception
File "/my_project/.venv/lib/python3.6/site-packages/googleapiclient/http.py" in _retry_request
162. resp, content = http.request(uri, method, *args, **kwargs)
File "/my_project/.venv/lib/python3.6/site-packages/oauth2client/transport.py" in new_request
175. redirections, connection_type)
File "/my_project/.venv/lib/python3.6/site-packages/oauth2client/transport.py" in request
282. connection_type=connection_type)
File "/my_project/.venv/lib/python3.6/site-packages/httplib2/__init__.py" in request
1322. (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/my_project/.venv/lib/python3.6/site-packages/httplib2/__init__.py" in _request
1072. (response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/my_project/.venv/lib/python3.6/site-packages/httplib2/__init__.py" in _conn_request
996. conn.request(method, request_uri, body, headers)
File "/usr/lib64/python3.6/http/client.py" in request
1239. self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib64/python3.6/http/client.py" in _send_request
1285. self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib64/python3.6/http/client.py" in endheaders
1234. self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib64/python3.6/http/client.py" in _send_output
1065. self.send(chunk)
File "/usr/lib64/python3.6/http/client.py" in send
986. self.sock.sendall(data)
File "/usr/lib64/python3.6/ssl.py" in sendall
965. v = self.send(data[count:])
File "/usr/lib64/python3.6/ssl.py" in send
935. return self._sslobj.write(data)
File "/usr/lib64/python3.6/ssl.py" in write
636. return self._sslobj.write(data)
Exception Type: BrokenPipeError at /ru/api/v1/my_url/
Exception Value: [Errno 32] Broken pipe
Request information:
USER: admin2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2018-07-30
@ulkoart

for starters, it would be logical to increase the timeout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question