Browse code

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.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@259 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2008/11/16 18:54:08
Showing 2 changed files
... ...
@@ -1,5 +1,9 @@
1 1
 2008-11-16  Michal Ludvig  <michal@logix.cz>
2 2
 
3
+	Merge from 0.9.8.x branch, rel 251:
4
+	* S3/S3.py: Adjusting previous commit (orig 249) - it's not a good idea 
5
+	  to retry ALL failures. Especially not those code=4xx where AmazonS3 
6
+	  servers are not happy with our requests.
3 7
 	Merge from 0.9.8.x branch, rel 249:
4 8
 	* S3/S3.py, S3/Exception.py: Re-issue failed requests in S3.send_request()
5 9
 	Merge from 0.9.8.x branch, rel 248:
... ...
@@ -319,9 +319,9 @@ class S3(object):
319 319
 			response["data"] =  http_response.read()
320 320
 			debug("Response: " + str(response))
321 321
 			conn.close()
322
-		except Exception:
322
+		except Exception, e:
323 323
 			if retries:
324
-				warning("Retrying failed request: %s" % resource['uri'])
324
+				warning("Retrying failed request: %s (%s)" % (resource['uri'], e))
325 325
 				return self.send_request(request, body, retries - 1)
326 326
 			else:
327 327
 				raise S3RequestError("Request failed for: %s" % resource['uri'])
... ...
@@ -334,12 +334,18 @@ class S3(object):
334 334
 			warning("Redirected to: %s" % (redir_hostname))
335 335
 			return self.send_request(request, body)
336 336
 
337
-		if response["status"] < 200 or response["status"] > 299:
337
+		if response["status"] >= 500:
338
+			e = S3Error(response)
338 339
 			if retries:
339
-				warning("Retrying failed request: %s" % resource['uri'])
340
+				warning(u"Retrying failed request: %s" % resource['uri'])
341
+				warning(unicode(e))
340 342
 				return self.send_request(request, body, retries - 1)
341 343
 			else:
342
-				raise S3Error(response)
344
+				raise e
345
+
346
+		if response["status"] < 200 or response["status"] > 299:
347
+			raise S3Error(response)
348
+
343 349
 		return response
344 350
 
345 351
 	def send_file(self, request, file, throttle = 0, retries = 3):