rackspace/python-cloudfiles — pull request #57 by michelts (2011-11-25 18:27:31+00:00)
Title: Retry request for send method

Fix for issues #26 and #50. Implements a retry request for the send method. I found 2 possible bugs this pull request solves:

1. When there is an delay between requests, as the issue #50 describes, the connection seems to be closed. We must retry the send method in this case. I did it and write a test.

2. When sending too large files or when dealing with network oscilations, we can reach the connection timeout. In this case, we must retry the connection too. I didn't write a test for it but I implemented a fix.

In both cases, the retry request is done once. This is important specially on the second case: if I set a low timeout, only one retry avoid a infinite loop.

I didn't write a test case for the second situation but it is pretty simple to test. Today, the code above would raise an ssl.SSLError:

```python
conn = cloudfiles.get_connection(username='xxx', api_key='yyy', timeout=LOW_TIMEOUT)
container = conn.get_container('some-container')
while 1:
file = open('some_large_file.jpg')
object = container.create_object('object.jpg')
object.send(file)
```

Again: this error may happens if we have a low timeout setting but can happens randomly due network oscilations (I think).

Thanks!