Skip to content

Instantly share code, notes, and snippets.

@viglesiasce
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save viglesiasce/9698586 to your computer and use it in GitHub Desktop.

Select an option

Save viglesiasce/9698586 to your computer and use it in GitHub Desktop.
import boto
import sys
import time
import random
import string
import os
from concurrent.futures import ThreadPoolExecutor
bucket = "music-backup"
print "Uploading to bucket: " + bucket
s3 = boto.connect_s3(host="walrus.home",aws_access_key_id="XXXXXXXX",aws_secret_access_key="YYYYYYYYY")
bucket = s3.get_bucket(bucket)
result_pool = []
with ThreadPoolExecutor(max_workers=50) as executor:
for i in xrange(1000):
contents = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(1024))
key_name = "test-key-" + str(int(time.time()))
key = bucket.new_key(key_name)
print "Putting key: " + key_name
result_pool.append(executor.submit(key.set_contents_from_string,contents))
for result in result_pool:
try:
result.result()
except:
print "Failed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment