Permalink
Browse files

Mods to retry logic for POST part of resumable uploads

  • Loading branch information...
1 parent 5e49c17 commit 741752d724258e31850e4f2ac7a88660b0a17e43 @mfschwartz mfschwartz committed Mar 11, 2011
Showing with 16 additions and 4 deletions.
  1. +15 −4 boto/gs/resumable_upload_handler.py
  2. +1 −0 desc
@@ -261,11 +261,22 @@ def _start_new_resumable_upload(self, key, headers=None):
'POST', key.bucket.name, key.name, post_headers)
# Get tracker URI from response 'Location' header.
body = resp.read()
- # Check for '201 Created' response code.
- if resp.status != 201:
+
+ # Check for various status conditions.
+ if resp.status == 500 or resp.status == 503:
+ # Retry status 500 and 503 errors after a delay.
+ raise ResumableUploadException(
+ 'Got status %d from attempt to start resumable upload. '
+ 'Will wait/retry' % resp.status,
+ ResumableTransferDisposition.WAIT_BEFORE_RETRY)
+ elif resp.status != 200 and resp.status != 201:
raise ResumableUploadException(
- 'Got status %d from attempt to start resumable upload' %
- resp.status, ResumableTransferDisposition.WAIT_BEFORE_RETRY)
+ 'Got status %d from attempt to start resumable upload. '
+ 'Aborting' % resp.status,
+ ResumableTransferDisposition.ABORT)
+
+ # Else we got 200 or 201 response code, indicating the resumable
+ # upload was created.
tracker_uri = resp.getheader('Location')
if not tracker_uri:
raise ResumableUploadException(
View
1 desc
@@ -0,0 +1 @@
+mods to retry logic for POST part of resumable upload logic

0 comments on commit 741752d

Please sign in to comment.