Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add return values to s3transfer tasks #247

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions s3transfer/copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,15 @@ def _main(
:param size: The size of the transfer. This value is passed into
the callbacks

:rtype: dict
:returns: A dictionary containing client response
"""
client.copy_object(
resp = client.copy_object(
CopySource=copy_source, Bucket=bucket, Key=key, **extra_args
)
for callback in callbacks:
callback(bytes_transferred=size)

return resp

class CopyPartTask(Task):
"""Task to upload a part in a multipart copy"""
Expand Down
4 changes: 3 additions & 1 deletion s3transfer/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ def _main(self, client, bucket, key, extra_args):
:type extra_args: dict
:param extra_args: Extra arguments to pass to the DeleteObject call.

:rtype: dict
:returns: A dictionary containing client response
"""
client.delete_object(Bucket=bucket, Key=key, **extra_args)
return client.delete_object(Bucket=bucket, Key=key, **extra_args)
10 changes: 7 additions & 3 deletions s3transfer/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ def _main(
content of the key to.
:param bandwidth_limiter: The bandwidth limiter to use when throttling
the downloading of data in streams.

:rtype: dict
:returns: A dictionary containing client response stripped of the
response Body
"""
last_exception = None
for i in range(max_attempts):
Expand All @@ -570,7 +574,7 @@ def _main(
Bucket=bucket, Key=key, **extra_args
)
streaming_body = StreamReaderProgress(
response['Body'], callbacks
response.pop('Body'), callbacks
)
if bandwidth_limiter:
streaming_body = (
Expand All @@ -593,8 +597,8 @@ def _main(
)
current_index += len(chunk)
else:
return
return
return response
return response
except S3_RETRYABLE_DOWNLOAD_ERRORS as e:
logger.debug(
"Retrying exception caught (%s), "
Expand Down
5 changes: 4 additions & 1 deletion s3transfer/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,11 @@ def _main(self, client, bucket, key, upload_id, parts, extra_args):
``UploadPartTask.main()``.
:param extra_args: A dictionary of any extra arguments that may be
used in completing the multipart transfer.

:rtype: dict
:returns: A dictionary containing client response
"""
client.complete_multipart_upload(
return client.complete_multipart_upload(
Bucket=bucket,
Key=key,
UploadId=upload_id,
Expand Down
5 changes: 4 additions & 1 deletion s3transfer/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,12 @@ def _main(self, client, fileobj, bucket, key, extra_args):
:param key: The name of the key to upload to
:param extra_args: A dictionary of any extra arguments that may be
used in the upload.

:rtype: dict
:returns: A dictionary containing client response
"""
with fileobj as body:
client.put_object(Bucket=bucket, Key=key, Body=body, **extra_args)
return client.put_object(Bucket=bucket, Key=key, Body=body, **extra_args)


class UploadPartTask(Task):
Expand Down