Skip to content

Instantly share code, notes, and snippets.

@clayg
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/9284386 to your computer and use it in GitHub Desktop.
Save clayg/9284386 to your computer and use it in GitHub Desktop.
import os
import time
from swiftclient import client
def body_iter(body, chunk_size=64):
backoff = 60
for i in range(len(body)):
chunk = body[i:i + chunk_size]
yield chunk
if i > 10 and backoff:
print 'sleeping for %s' % backoff
time.sleep(backoff)
print 'done with that then'
backoff = 0
auth_args = []
for key in ('auth', 'user', 'key'):
auth_args.append(os.environ['ST_%s' % key.upper()])
url, token = client.get_auth(*auth_args)
client.put_container(url, token, 'slow_container')
try:
headers, resp = client.put_object(url, token, 'slow_container', 'obj1',
contents=body_iter('a' * 1024))
except client.ClientException as e:
import pdb
pdb.set_trace()
print headers
print resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment