diff options
| author | Colin Stolley <colin@sproutsocial.com> | 2015-09-18 11:11:21 -0500 |
|---|---|---|
| committer | Colin Stolley <colin@sproutsocial.com> | 2015-09-18 11:19:52 -0500 |
| commit | 7ebbd4334d0a78b6b869729b7cbf19fd7ce98037 (patch) | |
| tree | 6a958c8617769a02c87be748649af60d0f008690 /python3/httplib2 | |
| parent | f69fe23a71ac58bde912af87dabf3057c4cd3c76 (diff) | |
| download | httplib2-7ebbd4334d0a78b6b869729b7cbf19fd7ce98037.tar.gz | |
Fix incorrect ResponseNotReady exceptions, retry on transient errors.
For socket errors besides Connection Refused, the code will swallow the
error and fall through to a misleading "ResponseNotReady" exception. This
is both incorrect and unhelpful. The code also does not retry on errors that
are potentially transient, ie, Network Unreachable or Address Not Available.
This patch addresses both concerns by raising the socket error so
that application code can handle it appropriately, or retrying if
the socket error is transient.
This likely resolves Issue #284 .
Diffstat (limited to 'python3/httplib2')
| -rw-r--r-- | python3/httplib2/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 @@ class Http(object): 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: |
