Skip to content
Browse files

Support for non-threaded multipart upload

Don't create thread-pool with Config().multipart_num_threads=1.
  • Loading branch information...
1 parent 344cadc commit 7698044a6289c1c8e1c184b59ecf75ec522a9d12 @mludvig mludvig committed Jan 3, 2012
Showing with 12 additions and 4 deletions.
  1. +12 −4 S3/MultiPart.py
View
16 S3/MultiPart.py
@@ -81,7 +81,11 @@ def upload_all_parts(self, num_threads, chunk_size):
chunk_size = max(self.MIN_CHUNK_SIZE, chunk_size)
id = 1
- pool = ThreadPool(num_threads)
+ if num_threads > 1:
+ debug("MultiPart: Uploading in %d threads" % num_threads)
+ pool = ThreadPool(num_threads)
+ else:
+ debug("MultiPart: Uploading in a single thread")
while True:
if id == self.MAX_CHUNKS:
@@ -90,11 +94,15 @@ def upload_all_parts(self, num_threads, chunk_size):
data = self.file.read(chunk_size)
if not data:
break
- pool.add_task(self.upload_part, data, id)
+ if num_threads > 1:
+ pool.add_task(self.upload_part, data, id)
+ else:
+ self.upload_part(data, id)
id += 1
- debug("Thread pool with %i threads and %i tasks awaiting completion." % (num_threads, id))
- pool.wait_completion()
+ if num_threads > 1:
+ debug("Thread pool with %i threads and %i tasks awaiting completion." % (num_threads, id))
+ pool.wait_completion()
def upload_part(self, data, id):
"""

0 comments on commit 7698044

Please sign in to comment.
Something went wrong with that request. Please try again.