This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 324
fix: updates timeout/retry code to respect hanging server #2408
Merged
chalmerlowe
merged 14 commits into
main
from
fix-468091307-update-timeout-retry-behavior
Jan 29, 2026
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0ca3d87
fix: updates timeout/retry code to respect hanging server
chalmerlowe f58d712
updates REST interactions to handle timeout
chalmerlowe f62c42b
updates time to monotonic
chalmerlowe 291cfe9
Update retry.py
chalmerlowe 6f0bad0
updates conditional statement to idiomatic python
chalmerlowe 2544afb
updates test suite to accommodate new timeout parameter
chalmerlowe 00eb8b5
revises retry deadline to accommodate the timeout.
chalmerlowe e5973a0
adds two tests to ensure proper coverage
chalmerlowe 90ef70f
updates mock
chalmerlowe 8ee106c
updates mock with subscriptable columns
chalmerlowe 60ae827
Updates tests to account for transitive dependency and older version …
chalmerlowe f263a8d
Removes accidentally added file
chalmerlowe 7e9b9f9
Updates tests with success case
chalmerlowe b7ea81a
merges content from temp file to permanent file, deletes temp file
chalmerlowe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import pytest | ||
| from unittest import mock | ||
| from google.cloud.bigquery import _pandas_helpers | ||
|
|
||
| try: | ||
| from google.cloud import bigquery_storage | ||
| except ImportError: | ||
| bigquery_storage = None | ||
|
|
||
|
|
||
| @pytest.mark.skipif( | ||
| bigquery_storage is None, reason="Requires `google-cloud-bigquery-storage`" | ||
| ) | ||
| def test_download_table_bqstorage_passes_timeout_to_create_read_session(): | ||
| # Mock dependencies | ||
| project_id = "test-project" | ||
| table = mock.Mock() | ||
| table.table_id = "test_table" | ||
| table.to_bqstorage.return_value = "projects/test/datasets/test/tables/test" | ||
|
|
||
| bqstorage_client = mock.Mock(spec=bigquery_storage.BigQueryReadClient) | ||
| # Mock create_read_session to return a session with no streams so the function returns early | ||
| # (Checking start of loop logic vs empty streams return) | ||
| session = mock.Mock() | ||
| # If streams is empty, _download_table_bqstorage returns early, which is fine for this test | ||
| session.streams = [] | ||
| bqstorage_client.create_read_session.return_value = session | ||
|
|
||
| # Call the function | ||
| timeout = 123.456 | ||
| # download_arrow_bqstorage yields frames, so we need to iterate to trigger execution | ||
| list( | ||
| _pandas_helpers.download_arrow_bqstorage( | ||
| project_id, table, bqstorage_client, timeout=timeout | ||
| ) | ||
| ) | ||
|
|
||
| # Verify timeout and retry were passed | ||
| bqstorage_client.create_read_session.assert_called_once() | ||
| _, kwargs = bqstorage_client.create_read_session.call_args | ||
| assert "timeout" in kwargs | ||
| assert kwargs["timeout"] == timeout | ||
|
|
||
| assert "retry" in kwargs | ||
| retry_policy = kwargs["retry"] | ||
| assert retry_policy is not None | ||
| # Check if deadline is set correctly in the retry policy | ||
| assert retry_policy._deadline == timeout |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.