Skip to content

Commit

Permalink
address offline feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jan 16, 2025
1 parent b7ea26e commit 5b9a2e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions google/api_core/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ def func_with_timeout(*args, **kwargs):
# is deprecated, and should be treated the same as the `timeout`,
# it is still possible for `deadline` argument in google.api_core.retry.Retry
# to be larger than the `timeout`.
# Avoid setting negative timeout or timeout less than 5 seconds when the `timeout`
# has expired.
# See https://github.com/googleapis/python-api-core/issues/654
# Revert back to the original timeout when this happens
if remaining_timeout < 5:
# Only positive non-zero timeouts are supported.
# Revert back to the initial timeout for negative or 0 timeout values.
if remaining_timeout < 1:
remaining_timeout = self._timeout

kwargs["timeout"] = remaining_timeout
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _clock():
wrapped()
target.assert_called_with(timeout=41.0)
wrapped()
target.assert_called_with(timeout=42.0)
target.assert_called_with(timeout=3.0)
wrapped()
target.assert_called_with(timeout=42.0)
wrapped()
Expand Down

0 comments on commit 5b9a2e8

Please sign in to comment.