Skip to content

Instantly share code, notes, and snippets.

@yuta-imai
Created November 7, 2014 15:20
Show Gist options
  • Save yuta-imai/1db0561fa9e177404de5 to your computer and use it in GitHub Desktop.
Save yuta-imai/1db0561fa9e177404de5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import Queue
from threading import Thread
import boto
import boto.s3
s3 = boto.s3.connect_to_region('ap-northeast-1')
bucket_name = sys.argv[1]
bucket = s3.get_bucket(bucket_name)
objects = bucket.list()
num_worker_threads = 50
q = Queue.Queue()
for object in objects:
q.put(object)
loop += 1
def worker():
while True:
item = q.get()
print bucket.delete_key(item.key)
q.task_done()
for i in range(num_worker_threads):
t = Thread(target=worker)
t.setDaemon(True)
t.start()
q.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment