rackspace/python-cloudfiles — Issue #60: create_object/load_from_filename/sync_metadata failing
Author: aljosa
Created: 2011-12-15 14:53:56+00:00
State: open

i'm trying to upload folder but after some time it breaks.
i've added try/except to restart upload and it did increase success rate but eventually it still fails.
any idea what i'm doing wrong?

i could retry upload until it succeeds but that is something i would expect core library to handle.

code and error:
conn = cloudfiles.get_connection(user, token)
c = conn.get_container('static')
for path, folders, files in walk("static"):
for f in files:
file = join(path, f)
print file
try:
obj = c.create_object(file)
obj.load_from_filename(file)
obj.headers["Access-Control-Allow-Origin"] = "*"
obj.sync_metadata()
except:
obj = c.create_object(file)
obj.load_from_filename(file)
obj.headers["Access-Control-Allow-Origin"] = "*"
obj.sync_metadata()

Traceback (most recent call last):
File "/home/aljosa/Projects/Sites/lsn/env/local/lib/python2.7/site-packages/fabric/main.py", line 682, in main
*args, **kwargs
File "/home/aljosa/Projects/Sites/lsn/env/local/lib/python2.7/site-packages/fabric/tasks.py", line 248, in execute
task.run(*args, **new_kwargs)
File "/home/aljosa/Projects/Sites/lsn/env/local/lib/python2.7/site-packages/fabric/tasks.py", line 105, in run
return self.wrapped(*args, **kwargs)
File "/home/aljosa/Projects/Sites/lsn/fabfile.py", line 39, in static_rackspace
obj.load_from_filename(file)
File "/home/aljosa/Projects/Sites/lsn/env/src/python-cloudfiles/cloudfiles/storage_object.py", line 548, in load_from_filename
self.write(fobj, verify=verify, callback=callback)
File "/home/aljosa/Projects/Sites/lsn/env/src/python-cloudfiles/cloudfiles/utils.py", line 45, in decorator
return f(*args, **kwargs)
File "/home/aljosa/Projects/Sites/lsn/env/src/python-cloudfiles/cloudfiles/storage_object.py", line 355, in write
response = http.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1027, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 407, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
line = self.fp.readline()
File "/usr/lib/python2.7/socket.py", line 430, in readline
data = recv(1)
File "/usr/lib/python2.7/ssl.py", line 232, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 151, in read
return self._sslobj.read(len)
ssl.SSLError: The read operation timed out