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

fix: apply timeout to all resumable upload requests #1070

Merged
merged 5 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/bigquery/client.py
Expand Up @@ -2850,7 +2850,7 @@ def _do_resumable_upload(
)

while not upload.finished:
response = upload.transmit_next_chunk(transport)
response = upload.transmit_next_chunk(transport, timeout=timeout)
plamut marked this conversation as resolved.
Show resolved Hide resolved

return response

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_client.py
Expand Up @@ -8235,6 +8235,22 @@ def test__do_resumable_upload_custom_project(self):
assert initiation_url is not None
assert "projects/custom-project" in initiation_url

def test__do_resumable_upload_custom_timeout(self):
file_obj = self._make_file_obj()
file_obj_len = len(file_obj.getvalue())
transport = self._make_transport(
self._make_resumable_upload_responses(file_obj_len)
)
client = self._make_client(transport)

client._do_resumable_upload(
file_obj, self.EXPECTED_CONFIGURATION, num_retries=0, timeout=3.14
)

# The timeout should be applied to all underlying calls.
for call_args in transport.request.call_args_list:
assert call_args.kwargs.get("timeout") == 3.14

def test__do_multipart_upload(self):
transport = self._make_transport([self._make_response(http.client.OK)])
client = self._make_client(transport)
Expand Down