Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improve handling of 503 errors; bump version to 0.10.14

  • Loading branch information...
commit b22c7601ef0886459ef729cc82d512598b585223 1 parent 80ec947
@bd4 bd4 authored
Showing with 13 additions and 11 deletions.
  1. +13 −11 globusonline/transfer/api_client/__init__.py
View
24 globusonline/transfer/api_client/__init__.py
@@ -68,7 +68,7 @@
"ServiceUnavailable", "Transfer", "Delete"]
# client version
-__version__ = "0.10.13"
+__version__ = "0.10.14"
class TransferAPIClient(object):
@@ -298,15 +298,15 @@ def do_request():
if attempt == self.max_attempts - 1:
raise
- # Check for ServiceUnavailable, which is treated just like
+ # Check for 503 ServiceUnavailable, which is treated just like
# network errors.
- if r is not None and attempt < self.max_attempts - 1:
- error_code = r.getheader("X-Transfer-API-Error", None)
- if error_code is not None \
- and error_code.startswith("ServiceUnavailable"):
- # Force sleep below and continue loop
- self.close()
- r = None
+ if (r is not None and r.status == 503
+ and attempt < self.max_attempts - 1):
+ # Force sleep below and continue loop, unless we are on
+ # the last attempt in which case skip this and return
+ # the 503 error.
+ self.close()
+ r = None
if r is not None:
break
@@ -334,8 +334,10 @@ def _request_json(self, method, path, body=None, content_type=None):
try:
data = json.loads(response_body)
except Exception as e:
- raise InterfaceError("Unable to parse JSON in response: "
- + str(e))
+ raise InterfaceError(
+ ("Unable to parse JSON in response: err='%s', "
+ +"body len='%d', status='%d %s'")
+ % (e, len(response_body), r.status, r.reason))
else:
data = None
return api_result(r, data)
Please sign in to comment.
Something went wrong with that request. Please try again.