Last active
December 23, 2015 01:49
-
-
Save fernandoflorez/6563062 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from gevent import monkey | |
from gevent.pool import Pool | |
from gevent import Timeout | |
monkey.patch_all() | |
import pyrax | |
if __name__ == '__main__': | |
pool = Pool(100) | |
pyrax.set_setting('identity_type', 'rackspace') | |
pyrax.set_setting('verify_ssl', False) | |
pyrax.set_credentials('username', 'api_key') | |
cf = pyrax.cloudfiles | |
container = cf.get_container('container_name') | |
objects = container.get_objects(full_listing=True) | |
def delete_object(obj): | |
# added timeout of 5 seconds just in case | |
with Timeout(5, False): | |
try: | |
obj.delete() | |
except: | |
pass | |
for obj in objects: | |
pool.spawn(delete_object, obj) | |
pool.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment