Permalink
Browse files

Compute speed and elapsed time for Multipart uploads

By the way fixes a crash with:
s3cmd put /xyz/big-file s3://bucket/ > /dev/null
Reported by HanJingYu
  • Loading branch information...
1 parent 7d047bd commit 9c57a3ba2163915deb2cc63cefa885a66ac377ab @mludvig mludvig committed Jan 17, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 S3/S3.py
View
@@ -752,11 +752,14 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries,
def send_file_multipart(self, file, headers, uri, size):
chunk_size = self.config.multipart_chunk_size_mb * 1024 * 1024
+ timestamp_start = time.time()
upload = MultiPartUpload(self, file, uri, headers)
upload.upload_all_parts()
response = upload.complete_multipart_upload()
- response["speed"] = 0 # XXX
+ timestamp_end = time.time()
+ response["elapsed"] = timestamp_end - timestamp_start
response["size"] = size
+ response["speed"] = response["elapsed"] and float(response["size"]) / response["elapsed"] or float(-1)
return response
def recv_file(self, request, stream, labels, start_position = 0, retries = _max_retries):

0 comments on commit 9c57a3b

Please sign in to comment.