Skip to content

Commit

Permalink
Merge pull request jcgregorio#313 from ccstolley/master
Browse files Browse the repository at this point in the history
Fix incorrect ResponseNotReady exceptions, retry on transient errors.
  • Loading branch information
jcgregorio committed Sep 21, 2015
2 parents f69fe23 + 7ebbd43 commit d86146d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions python2/httplib2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,9 @@ def _conn_request(self, conn, request_uri, method, body, headers):
err = getattr(e, 'args')[0]
else:
err = e.errno
if err == errno.ECONNREFUSED: # Connection refused
raise
if err in (errno.ENETUNREACH, errno.EADDRNOTAVAIL) and i < RETRIES:
continue # retry on potentially transient socket errors
raise
except httplib.HTTPException:
# Just because the server closed the connection doesn't apparently mean
# that the server didn't send a response.
Expand Down
5 changes: 3 additions & 2 deletions python3/httplib2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,9 @@ def _conn_request(self, conn, request_uri, method, body, headers):
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
except socket.error as e:
errno_ = (e.args[0].errno if isinstance(e.args[0], socket.error) else e.errno)
if errno_ == errno.ECONNREFUSED: # Connection refused
raise
if errno_ in (errno.ENETUNREACH, errno.EADDRNOTAVAIL) and i < RETRIES:
continue # retry on potentially transient errors
raise
except http.client.HTTPException:
if conn.sock is None:
if i < RETRIES-1:
Expand Down

0 comments on commit d86146d

Please sign in to comment.