Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Understanding `num_retries` in `discovery.build()`? #1049
File "/usr/local/lib/python3.8/dist-packages/my_app-0.3.1-py3.8.egg/my_app/data/gd.py", line 58, in __init__ self.drive = googleapiclient.discovery.build('drive', 'v3', http=auth_http) File "/usr/local/lib/python3.8/dist-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper return wrapped(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/googleapiclient/discovery.py", line 292, in build raise e File "/usr/local/lib/python3.8/dist-packages/googleapiclient/discovery.py", line 268, in build content = _retrieve_discovery_doc( File "/usr/local/lib/python3.8/dist-packages/googleapiclient/discovery.py", line 365, in _retrieve_discovery_doc resp, content = req.execute(num_retries=num_retries) File "/usr/local/lib/python3.8/dist-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper return wrapped(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/googleapiclient/http.py", line 907, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 502 when requesting https://www.googleapis.com/discovery/v1/apis/drive/v3/rest returned "Bad Gateway">
I could read about this error from this SO thread.
Additionally, Google doc suggests to address 5xx HttpError with a retry strategy.
So my trouble seems like easy to solve with this parameter. Nonetheless I have 2 questions.
QUESTION 1: Setting an appropriate
Thanks a lot for your help and support.
@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
🤖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).