Skip to content

Instantly share code, notes, and snippets.

@shuhaowu
Created January 29, 2014 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuhaowu/8696406 to your computer and use it in GitHub Desktop.
Save shuhaowu/8696406 to your computer and use it in GitHub Desktop.
Purges all keys from riak via python.
import riak
import multiprocessing
keys = []
c = riak.RiakClient()
for b in c.get_buckets():
k = [(b.name, key) for key in b.get_keys()]
keys.extend(k)
print len(keys)
def f(args):
c = riak.RiakClient()
b, key = args
print "Deleting", key, b, multiprocessing.current_process()
c.bucket(b).delete(key)
pool = multiprocessing.Pool()
pool.map_async(f, keys, 100)
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment