Skip to content
This repository has been archived by the owner on Nov 4, 2018. It is now read-only.

Commit

Permalink
Merge from 0.9.8.x branch, rel 251:
Browse files Browse the repository at this point in the history
* S3/S3.py: Adjusting previous commit (orig 249) - it's not a good idea 
  to retry ALL failures. Especially not those code=4xx where AmazonS3 
  servers are not happy with our requests.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@259 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
mludvig committed Nov 16, 2008
1 parent 00f5f67 commit f228b03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,5 +1,9 @@
2008-11-16 Michal Ludvig <michal@logix.cz>

Merge from 0.9.8.x branch, rel 251:
* S3/S3.py: Adjusting previous commit (orig 249) - it's not a good idea
to retry ALL failures. Especially not those code=4xx where AmazonS3
servers are not happy with our requests.
Merge from 0.9.8.x branch, rel 249:
* S3/S3.py, S3/Exception.py: Re-issue failed requests in S3.send_request()
Merge from 0.9.8.x branch, rel 248:
Expand Down
16 changes: 11 additions & 5 deletions S3/S3.py
Expand Up @@ -319,9 +319,9 @@ def send_request(self, request, body = None, retries = 5):
response["data"] = http_response.read()
debug("Response: " + str(response))
conn.close()
except Exception:
except Exception, e:
if retries:
warning("Retrying failed request: %s" % resource['uri'])
warning("Retrying failed request: %s (%s)" % (resource['uri'], e))
return self.send_request(request, body, retries - 1)
else:
raise S3RequestError("Request failed for: %s" % resource['uri'])
Expand All @@ -334,12 +334,18 @@ def send_request(self, request, body = None, retries = 5):
warning("Redirected to: %s" % (redir_hostname))
return self.send_request(request, body)

if response["status"] < 200 or response["status"] > 299:
if response["status"] >= 500:
e = S3Error(response)
if retries:
warning("Retrying failed request: %s" % resource['uri'])
warning(u"Retrying failed request: %s" % resource['uri'])
warning(unicode(e))
return self.send_request(request, body, retries - 1)
else:
raise S3Error(response)
raise e

if response["status"] < 200 or response["status"] > 299:
raise S3Error(response)

return response

def send_file(self, request, file, throttle = 0, retries = 3):
Expand Down

0 comments on commit f228b03

Please sign in to comment.