Skip to content

Instantly share code, notes, and snippets.

@robbyt
Created January 7, 2012 07:29
Show Gist options
  • Save robbyt/1574105 to your computer and use it in GitHub Desktop.
Save robbyt/1574105 to your computer and use it in GitHub Desktop.
cloudfiles and eventlet
import eventlet
cloudfiles = eventlet.import_patched('cloudfiles')
username = 'foo'
api_key = 'bar'
buckets = ['list', 'of', 'buckets', 'to', 'create']
cf_pool = pools.Pool(create=lambda: cloudfiles.get_connection(username, api_key)
def create_buckets(bucket):
with cf_pool.item() as cf_p:
response = cf_p.create_container(bucket)
return response
pile = eventlet.GreenPile()
for b in buckets:
pile.spawn(create_bucket, b)
responses = list(pile)
print responses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment