+# Blue Sky: File Systems in the Cloud
+#
+# Copyright (C) 2011 The Regents of the University of California
+# Written by Michael Vrable <mvrable@cs.ucsd.edu>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
"""A simple Python library for accessing the Windows Azure blob service."""
import base64, hashlib, hmac, httplib, os, time, urllib
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))