Skip to content

Retry ConnectionResetError exceptions #12

@sfontana

Description

@sfontana

From time to time I get a ConnectionResetError while getting the data.

We should retry these (we don't see any downside with that...yet).
Make sure to check whether ConnectionResetError is the same kind of exception in both py3 and py2.

Here's an example stacktrace:

Traceback (most recent call last):
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/IPython/core/formatters.py", line 224, in catch_format_error
    r = method(self, *args, **kwargs)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/IPython/core/formatters.py", line 702, in __call__
    printer.pretty(obj)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/IPython/lib/pretty.py", line 402, in pretty
    return _repr_pprint(obj, self, cycle)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/IPython/lib/pretty.py", line 697, in _repr_pprint
    output = repr(obj)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/view.py", line 115, in __repr__
    return str('View(%r)') % (self._view_rows,)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/view.py", line 217, in __repr__
    return repr(list(self))
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/view.py", line 212, in __iter__
    self._view._ensure_cells_fetched()
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/api.py", line 45, in wrapper
    return _do_exp_backoff(partial_func, MAX_WAIT_TIME)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/api.py", line 99, in _do_exp_backoff
    return func()
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/hyou/view.py", line 58, in _ensure_cells_fetched
    **self._fetch_params).execute()
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/googleapiclient/http.py", line 837, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/googleapiclient/http.py", line 162, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/google_auth_httplib2.py", line 198, in request
    uri, method, body=body, headers=request_headers, **kwargs)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/httplib2/__init__.py", line 1514, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/httplib2/__init__.py", line 1264, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/Users/stefano/.virtualenvs/lara/lib/python3.6/site-packages/httplib2/__init__.py", line 1217, in _conn_request
    response = conn.getresponse()
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 54] Connection reset by peer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions