path = "/%s/%s" % (container, key)
r = self._make_request(path, method='DELETE')
+def parallel_delete(container, keys):
+ import Queue
+ from threading import Lock, Thread
+
+ keys = list(iter(keys))
+
+ q = Queue.Queue(16384)
+ l = Lock()
+
+ def deletion_task():
+ conn = AzureConnection()
+ while True:
+ k = q.get()
+ l.acquire()
+ print k
+ l.release()
+ conn.delete(container, k)
+ q.task_done()
+
+ for i in range(128):
+ t = Thread(target=deletion_task)
+ t.setDaemon(True)
+ t.start()
+
+ for k in keys:
+ q.put(k)
+ q.join()
+
if __name__ == '__main__':
container = 'bluesky'
conn = AzureConnection()
conn.put(container, "testkey", "A" * 40)
print "Fetch result:", conn.get(container, "testkey")
- for k in list(iter(conn.list(container))):
- print "Deleting", k
- conn.delete(container, k)
+ parallel_delete(container, conn.list(container))