question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken Pipe exceptions raised after idle periods

See original GitHub issue

I’m using long-lived client objects like so:

client = discovery.build(....)
task = client.get_something(....).execute(num_retries=5)
some_long_running_process(task)
client.do_another_thing().execute(num_retries=5)

And running into exceptions on the calls to do_another_thing():

Traceback (most recent call last):
  File "/opt/app/gcp_helper.py", line 168, in get_size
    instanceGroupManager=instance_group).execute(num_retries=5)
  File "/opt/venv/local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/opt/venv/local/lib/python2.7/site-packages/googleapiclient/http.py", line 755, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "/opt/venv/local/lib/python2.7/site-packages/googleapiclient/http.py", line 93, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/opt/venv/local/lib/python2.7/site-packages/oauth2client/client.py", line 633, in new_request
    self._refresh(request_orig)
  File "/opt/venv/local/lib/python2.7/site-packages/oauth2client/contrib/gce.py", line 129, in _refresh
    META, headers={'Metadata-Flavor': 'Google'})
  File "/opt/venv/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1609, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/opt/venv/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1351, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/opt/venv/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1273, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 826, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 32] Broken pipe"

I would expect the num_retries argument to handle these exceptions in https://github.com/google/google-api-python-client/blob/master/googleapiclient/http.py#L145, but for the time being I have to implement my own retry logic around all API calls to overcome this.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:48 (16 by maintainers)

github_iconTop GitHub Comments

13reactions
jannehcommented, Feb 19, 2019

I’m experiencing this issue as well…

Using:

Python 3.6.7

>>> import googleapiclient
>>> googleapiclient.__version__
'1.7.8'

Stack trace:

File "/var/task/pubsub_publisher.py", line 42, in handler
  pubsub.projects().topics().publish(topic=_GOOGLE_PUBSUB_TOPIC_NAME, body=body).execute() 
File "/var/task/googleapiclient/_helpers.py", line 130, in positional_wrapper
  return wrapped(*args, **kwargs)
File "/var/task/googleapiclient/http.py", line 846, in execute
  method=str(self.method), body=self.body, headers=self.headers)
File "/var/task/googleapiclient/http.py", line 183,in _retry_request
  raise exception
File "/var/task/googleapiclient/http.py", line 164, in _retry_request
  resp, content = http.request(uri, method, *args, **kwargs)
File "/var/task/google_auth_httplib2.py", line 198, in request
  uri, method, body=body, headers=request_headers, **kwargs)
File "/var/task/httplib2/__init__.py", line 1924, in request
  cachekey,
File "/var/task/httplib2/__init__.py", line 1595, in _request
  conn, request_uri, method, body, headers
File "/var/task/httplib2/__init__.py", line 1502, in _conn_request
  conn.request(method, request_uri, body, headers)
File "/var/lang/lib/python3.6/http/client.py", line 1239, in request
  self._send_request(method, url, body, headers, encode_chunked)
File "/var/lang/lib/python3.6/http/client.py", line 1285, in _send_request
  self.endheaders(body, encode_chunked=encode_chunked)
File "/var/lang/lib/python3.6/http/client.py", line 1234, in endheaders
  self._send_output(message_body, encode_chunked=encode_chunked)
File "/var/lang/lib/python3.6/http/client.py", line 1065, in _send_output
  self.send(chunk)
File "/var/lang/lib/python3.6/http/client.py", line 986, in send
  self.sock.sendall(data)
File "/var/lang/lib/python3.6/ssl.py", line 975, in sendall
  v = self.send(byte_view[count:])
File "/var/lang/lib/python3.6/ssl.py", line 944, in send
  return self._sslobj.write(data)
File "/var/lang/lib/python3.6/ssl.py", line 642, in write
  return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe

It’s something that happens now and then, not super common. Constantly recurring though.

As an example in a sample of 7,741,334 publishes I have 6 of those errors.

5reactions
theacodescommented, Nov 2, 2016

@Bobspadger probably not, but we’re soon replacing oauth2client in this library with google-auth, which will allow us to use urllib3 and requests without needing httplib2shim.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Broken Pipe - Socket Exception - with latest version of Hibernate
Looks like this issue is happening if the application has no activity with the database for a considerable amount of time (say 12...
Read more >
java.net.SocketException: Broken pipe in WSA after two hours ...
The exception is only thrown after a two hour time period between calls to the WSA. Error Message. DISCONNECT IOException: java.net.
Read more >
How to Fix java.net.SocketException: Broken pipe in ... - Java67
These broken pipe exceptions happen when the client (browser) has closed the connection, but the server (your tag) continues to try to write...
Read more >
CPE3455 - Broken Pipe in DDM, DRDA clients - IBM
DDM and DRDA client applications which have significant periods where communication is idle may receive a CPE3455 "Broken pipe" error when ...
Read more >
Frequent java.io.IOException: broken pipe messages ... - Jira
Our findings show that this exception is a symptom rather than a cause. ... This can happen as well with anything that is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found