Merge pull request #313 from ccstolley/master
Fix incorrect ResponseNotReady exceptions, retry on transient errors.
diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py
index 19e7cff..f0d17a1 100644
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -1285,8 +1285,9 @@
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.
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index 260fa6b..ad5cc7f 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -994,8 +994,9 @@
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: