diff options
| author | jason | 2009-12-18 13:10:19 -0700 |
|---|---|---|
| committer | jason | 2009-12-18 13:10:19 -0700 |
| commit | 1196f449a3f2faa7267949e586f12920eb2194a2 (patch) | |
| tree | 97c7e8b5bf5c6045ee94b9a4f79512dd539e7cdd | |
| parent | f5f678a8cd51d434c55efdaecaaddf2b32f25bb1 (diff) | |
| download | amazons3-py-1196f449a3f2faa7267949e586f12920eb2194a2.tar.gz amazons3-py-1196f449a3f2faa7267949e586f12920eb2194a2.zip | |
Added a try/except to retry sending the file is the connection was reset by peer
| -rw-r--r-- | S3.py | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -272,7 +272,13 @@ class AWSAuthConnection: | |||
| 272 | # add auth header | 272 | # add auth header |
| 273 | self._add_aws_auth_header(final_headers, method, bucket, key, query_args) | 273 | self._add_aws_auth_header(final_headers, method, bucket, key, query_args) |
| 274 | 274 | ||
| 275 | connection.request(method, path, data, final_headers) | 275 | try: |
| 276 | connection.request(method, path, data, final_headers) | ||
| 277 | except: | ||
| 278 | # Sometimes the connection is reset by peer. If that happens | ||
| 279 | # just try it again and we'll see what happens. | ||
| 280 | connection.request(method, path, data, final_headers) | ||
| 281 | |||
| 276 | resp = connection.getresponse() | 282 | resp = connection.getresponse() |
| 277 | if resp.status < 300 or resp.status >= 400: | 283 | if resp.status < 300 or resp.status >= 400: |
| 278 | return resp | 284 | return resp |
| @@ -475,7 +481,7 @@ class ListBucketResponse(Response): | |||
| 475 | class ListAllMyBucketsResponse(Response): | 481 | class ListAllMyBucketsResponse(Response): |
| 476 | def __init__(self, http_response): | 482 | def __init__(self, http_response): |
| 477 | Response.__init__(self, http_response) | 483 | Response.__init__(self, http_response) |
| 478 | if http_response.status < 300: | 484 | if http_response.status < 300: |
| 479 | handler = ListAllMyBucketsHandler() | 485 | handler = ListAllMyBucketsHandler() |
| 480 | xml.sax.parseString(self.body, handler) | 486 | xml.sax.parseString(self.body, handler) |
| 481 | self.entries = handler.entries | 487 | self.entries = handler.entries |
| @@ -501,7 +507,7 @@ class GetResponse(Response): | |||
| 501 | class LocationResponse(Response): | 507 | class LocationResponse(Response): |
| 502 | def __init__(self, http_response): | 508 | def __init__(self, http_response): |
| 503 | Response.__init__(self, http_response) | 509 | Response.__init__(self, http_response) |
| 504 | if http_response.status < 300: | 510 | if http_response.status < 300: |
| 505 | handler = LocationHandler() | 511 | handler = LocationHandler() |
| 506 | xml.sax.parseString(self.body, handler) | 512 | xml.sax.parseString(self.body, handler) |
| 507 | self.location = handler.location | 513 | self.location = handler.location |