| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| Expand Up | @@ -102,8 +102,7 @@ def __call__(self, func): | |||
| def func_with_timeout(*args, **kwargs): | ||||
| """Wrapped function that adds timeout.""" | ||||
|
|
||||
| remaining_timeout = self._timeout | ||||
| if remaining_timeout is not None: | ||||
| if self._timeout is not None: | ||||
| # All calculations are in seconds | ||||
| now_timestamp = self._clock().timestamp() | ||||
|
|
||||
| Expand All | @@ -114,8 +113,19 @@ def func_with_timeout(*args, **kwargs): | |||
| now_timestamp = first_attempt_timestamp | ||||
|
|
||||
| time_since_first_attempt = now_timestamp - first_attempt_timestamp | ||||
| # Avoid setting negative timeout | ||||
| kwargs["timeout"] = max(0, self._timeout - time_since_first_attempt) | ||||
| remaining_timeout = self._timeout - time_since_first_attempt | ||||
|
|
||||
| # Although the `deadline` parameter in `google.api_core.retry.Retry` | ||||
| # is deprecated, and should be treated the same as the `timeout`, | ||||
| # it is still possible for the `deadline` argument in | ||||
| # `google.api_core.retry.Retry` to be larger than the `timeout`. | ||||
|
Comment thread
Comment on lines
+120
to
+121
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis does not explain how the deadline value enters here since there's no deadline in this function. It's confusing. Please clarify.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe deadline enters via wrap_method linked below, and is used in the calculation for an overall timeout. The fact that there is a separate deadline that can be confirmed is unexpected behavior which will be addressed in a follow up PR.
Sorry, something went wrong.
All reactions
|
||||
| # See https://github.com/googleapis/python-api-core/issues/654 | ||||
| # 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 | ||||
|
Comment thread
Comment on lines
+125
to
+126
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't understand this. This seems to be saying that if the next server-RPC timeout is ~0, we should reset it to be the GAPIC-surface level timeout, which seems wrong. I assume we're checking the GAPIC-surface level timeout elsewhere? Where? If we are indeed checking it elsewhere, clarify that here, and explain how the scenario leading up to this situation means it should be reset to self._timeout instead of, say, 5.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYou're right @vchudnov-g , there is existing incorrect behavior and this simply avoids the specific failure of sending requests with an rpc timeout of 0, which fail immediately. More clarity is needed to document the current incorrect behavior and the workaround in this PR, as well as the recommended long term fix. As per offline discussion, we'll merge this as is and follow up with another PR to update the comments to provide more clarity.
Sorry, something went wrong.
All reactions
|
||||
|
|
||||
| kwargs["timeout"] = remaining_timeout | ||||
|
|
||||
| return func(*args, **kwargs) | ||||
|
|
||||
| Expand Down | ||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think this self._timeout is meant to be treated as the total timeout and not a timeout for each retry.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThere is some clean up that needs to happen as part of a longer term fix (Googlers see b/388247478) but for now I'd recommend to keep the definitions unchanged.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.