Skip to content

Commit b508809

Browse files
authored
fix: populate default timeout and retry after client-side timeout (#896)
This addresses internal issue 195337762 where sometimes query job creation can take longer than expected and retrying the API call can be faster than waiting for the first query job request to fail. Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #889 Towards #779 🦕
1 parent 1cb3e55 commit b508809

14 files changed

+282
-219
lines changed

google/cloud/bigquery/client.py

+62-61
Large diffs are not rendered by default.

google/cloud/bigquery/retry.py

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
exceptions.BadGateway,
3030
requests.exceptions.ChunkedEncodingError,
3131
requests.exceptions.ConnectionError,
32+
requests.exceptions.Timeout,
3233
auth_exceptions.TransportError,
3334
)
3435

@@ -59,6 +60,13 @@ def _should_retry(exc):
5960
pass ``retry=bigquery.DEFAULT_RETRY.with_deadline(30)``.
6061
"""
6162

63+
DEFAULT_TIMEOUT = 5.0 * 60.0
64+
"""The default API timeout.
65+
66+
This is the time to wait per request. To adjust the total wait time, set a
67+
deadline on the retry object.
68+
"""
69+
6270
job_retry_reasons = "rateLimitExceeded", "backendError"
6371

6472

noxfile.py

-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ def snippets(session):
160160
if os.environ.get("RUN_SNIPPETS_TESTS", "true") == "false":
161161
session.skip("RUN_SNIPPETS_TESTS is set to false, skipping")
162162

163-
# Sanity check: Only run snippets tests if the environment variable is set.
164-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
165-
session.skip("Credentials must be set via environment variable.")
166-
167163
constraints_path = str(
168164
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
169165
)

0 commit comments

Comments
 (0)