-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Understanding num_retries
in discovery.build()
?
#1049
Comments
@yohplala, thank you for your questions. In regards to guidance related to appropriate number of retries: Guidance of setting a number of retries can vary, but we suggest that using large number of retries should not be considered as a mechanism to avoid longer endpoint outages. Retries with exponential backoff (with jitter) is well-known mechanism in the industry, and it is positioned as a correct response of a well-behaved client to occasional, short-lived throttling (503) or gateway timeouts (504). In fact, we should probably reconsider making error 502 retriable as it signifies an invalid response from the upstream server, therefore making 502 errors not temporal or transient in nature. Answering your second question: yes, the number of retries is passed to downstream methods. If you take a look at this line, Finally, thank you for reporting a miss in documentation update. We will refresh the docs to properly document usage of |
Thanks @DFrenkel for your very complete answer! |
Updates for both discovery docs and epydoc API Documentation Fixes: #1049
🤖 I have created a release \*beep\* \*boop\* --- ### [1.12.4](https://www.github.com/googleapis/google-api-python-client/compare/v1.12.3...v1.12.4) (2020-10-20) ### Bug Fixes * don't set content-range on empty uploads ([#1070](https://www.github.com/googleapis/google-api-python-client/issues/1070)) ([af6035f](https://www.github.com/googleapis/google-api-python-client/commit/af6035f6754a155ee6b04bbbc5c39410c7316d6a)) ### Documentation * fix typo in oauth.md ([#1058](https://www.github.com/googleapis/google-api-python-client/issues/1058)) ([30eff9d](https://www.github.com/googleapis/google-api-python-client/commit/30eff9d8276919b8c4e50df2d3b1982594423692)) * update generated docs ([#1053](https://www.github.com/googleapis/google-api-python-client/issues/1053)) ([3e17f89](https://www.github.com/googleapis/google-api-python-client/commit/3e17f8990db54bec16c48c319072799a14f5a53f)), closes [#1049](https://www.github.com/googleapis/google-api-python-client/issues/1049) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
the |
Yes, the number of retries is passed to downstream methods during discovery. I cover this aspect in my comment above:
|
@DFrenkel there is a dependency for Link to code that you've provided in previous comment link to commit is pointing to old commit. If |
Hi @DFrenkel @busunkim96,
CONTEXT
Recently, I got an
HttpError 502
when runninggoogleapiclient.discovery.build()
.I could read about this error from this SO thread.
Quest.
Is anyone else getting a 502 Bad Gateway error when trying to access https://www.googleapis.com/discovery/v1/apis/drive/v2/rest
Ans.
It appears to have started working again after being down for ~ 1 hr. Nothing needed to be done.
Additionally, Google doc suggests to address 5xx HttpError with a retry strategy.
Heading in this direction, I finally noticed that a num_retries made its apparition in
build
a few weeks ago thanks to you @DFrenkel 👍 (PR)So my trouble seems like easy to solve with this parameter. Nonetheless I have 2 questions.
QUESTION 1: Setting an appropriate
num_retries
valuenum_retries
from this max time?I read the formula used to assess the sleep time between 2 retries:
google-api-python-client/googleapiclient/http.py
Line 162 in 2d076b8
random()
giving a number between 0 and 1, I considered it being equal to 0.5. I could then see that with 12 retries, I could have a process retrying for about 1hr 10 minutes. Do you consider this correct?QUESTION 2:
num_retries
inheritance?Does the subsequent
num_retries
inexecute()
inherit as default value the value set fornum_retries
inbuild()
?Thanks a lot for your help and support.
Have a good day,
Bests,
PS:
num_retries
does not appear documented yet in source doc, which is where I 1st looked to see how I could implement it.I most notably found this other thread, suggesting to subclass
HttpRequest
, with defaultnum_retries
. Seemed like another level of work to conduct, and very happy you could implement it directly inbuild()
! :) Thanks!The text was updated successfully, but these errors were encountered: