Created
January 7, 2012 07:29
-
-
Save robbyt/1574105 to your computer and use it in GitHub Desktop.
cloudfiles and eventlet
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 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