Last active
August 29, 2015 13:56
-
-
Save clayg/9284386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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