Skip to content

Commit 765c1b1

Browse files
authored
Merge branch 'main' into update_mypy
2 parents 917f202 + d8ca706 commit 765c1b1

File tree

7 files changed

+254
-22
lines changed

7 files changed

+254
-22
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:a1c5112b81d645f5bbc4d4bbc99d7dcb5089a52216c0e3fb1203a0eeabadd7d5
17-
# created: 2025-01-02T23:09:36.975468657Z
16+
digest: sha256:04c35dc5f49f0f503a306397d6d043685f8d2bb822ab515818c4208d7fb2db3a
17+
# created: 2025-01-16T15:24:11.364245182Z
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
nox
2+
gcp-docuploader

.kokoro/docker/docs/requirements.txt

Lines changed: 234 additions & 9 deletions
Large diffs are not rendered by default.

.kokoro/publish-docs.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export PYTHONUNBUFFERED=1
2020

2121
export PATH="${HOME}/.local/bin:${PATH}"
2222

23-
# Install nox
24-
python3.10 -m pip install --require-hashes -r .kokoro/requirements.txt
25-
python3.10 -m nox --version
26-
2723
# build docs
2824
nox -s docs
2925

google/api_core/timeout.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ def __call__(self, func):
102102
def func_with_timeout(*args, **kwargs):
103103
"""Wrapped function that adds timeout."""
104104

105-
remaining_timeout = self._timeout
106-
if remaining_timeout is not None:
105+
if self._timeout is not None:
107106
# All calculations are in seconds
108107
now_timestamp = self._clock().timestamp()
109108

@@ -114,8 +113,19 @@ def func_with_timeout(*args, **kwargs):
114113
now_timestamp = first_attempt_timestamp
115114

116115
time_since_first_attempt = now_timestamp - first_attempt_timestamp
117-
# Avoid setting negative timeout
118-
kwargs["timeout"] = max(0, self._timeout - time_since_first_attempt)
116+
remaining_timeout = self._timeout - time_since_first_attempt
117+
118+
# Although the `deadline` parameter in `google.api_core.retry.Retry`
119+
# is deprecated, and should be treated the same as the `timeout`,
120+
# it is still possible for the `deadline` argument in
121+
# `google.api_core.retry.Retry` to be larger than the `timeout`.
122+
# See https://github.com/googleapis/python-api-core/issues/654
123+
# Only positive non-zero timeouts are supported.
124+
# Revert back to the initial timeout for negative or 0 timeout values.
125+
if remaining_timeout < 1:
126+
remaining_timeout = self._timeout
127+
128+
kwargs["timeout"] = remaining_timeout
119129

120130
return func(*args, **kwargs)
121131

renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
":preserveSemverRanges",
66
":disableDependencyDashboard"
77
],
8-
"ignorePaths": [".pre-commit-config.yaml", ".kokoro/requirements.txt", "setup.py"],
8+
"ignorePaths": [".pre-commit-config.yaml", ".kokoro/requirements.txt", "setup.py", ".github/workflows/unittest.yml"],
99
"pip_requirements": {
1010
"fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"]
1111
}

tests/unit/test_timeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def _clock():
8484
wrapped()
8585
target.assert_called_with(timeout=3.0)
8686
wrapped()
87-
target.assert_called_with(timeout=0.0)
87+
target.assert_called_with(timeout=42.0)
8888
wrapped()
89-
target.assert_called_with(timeout=0.0)
89+
target.assert_called_with(timeout=42.0)
9090

9191
def test_apply_no_timeout(self):
9292
target = mock.Mock(spec=["__call__", "__name__"], __name__="target")

0 commit comments

Comments
 (0)