GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix: add ConnectionError to default retry by cojenco · Pull Request #445 · googleapis/python-storage
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Conversation
Contributor
This adds python built-in ConnectionError to default retryable types. Fixes #426 🦕
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
cojenco
marked this pull request as draft
tritone
reviewed
|
|
|
||
|
|
||
| _RETRYABLE_TYPES = ( | ||
| ConnectionError, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ConnectionError has a bunch of subclasses: https://docs.python.org/3/library/exceptions.html#ConnectionError . Just wanted to confirm that we consider all of these retryable?
Also, is there a test where we should add this as a test case?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One or more tests should be added to the Test_should_retry class in tests/unit/test_retry.py (see the BigQuery PR for examples).
Also, that PR makes requests.exceptions.ConnectionError an explicit retryable type. The requests version does not derive from the stdlib type:
$ .nox/unit-3-9/bin/python Python 3.9.0 (default, Apr 20 2021, 11:50:03) [GCC 9.3.0] on linux >>> import requests.exceptions >>> requests.exceptions.ConnectionError <class 'requests.exceptions.ConnectionError'> >>> requests.exceptions.ConnectionError.__mro__ (<class 'requests.exceptions.ConnectionError'>, <class 'requests.exceptions.RequestException'>, <class 'OSError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Note that ConnectionError is not a stdlib type in Python 2.7:
$ .nox/unit-2-7/bin/python Python 2.7.17 (default, Apr 20 2021, 14:27:04) [GCC 9.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ConnectionError Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'ConnectionError' is not defined
We need to do something like:
try: _RETRYABLE_STDLIB_TYPES = {ConnectionError,) except NameError: _RETRYABLE_STDLIB_TYPES = {}
and then, below:
RETRYABLE_TYPES = _RETRYABLE_STDLIB_TYPES + ( api_exceptions.TooManyRequests, # 429 ... )
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@tritone @tseaver Thanks for reviewing! Looking at the python3 docs and previous discussion in the Big Query, ConnectionError and its subclasses are retryable. From users feedback, this error occurs when there are multiple Cloud Functions running and/or subsequent reinvocation of Cloud Functions. The retry test is set up with a loop that tests each default retry. I'll double check to make the changes and add one or more specific tests. Thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@tseaver I noticed that ConnectionError is not a stdlib type in Python 2.7 upon submission. Changed PR to draft to implement changes. This is exactly what I need. Thanks so much for the pointers!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
|
|
||
| _RETRYABLE_TYPES = ( | ||
| ConnectionError, |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One or more tests should be added to the Test_should_retry class in tests/unit/test_retry.py (see the BigQuery PR for examples).
Also, that PR makes requests.exceptions.ConnectionError an explicit retryable type. The requests version does not derive from the stdlib type:
$ .nox/unit-3-9/bin/python Python 3.9.0 (default, Apr 20 2021, 11:50:03) [GCC 9.3.0] on linux >>> import requests.exceptions >>> requests.exceptions.ConnectionError <class 'requests.exceptions.ConnectionError'> >>> requests.exceptions.ConnectionError.__mro__ (<class 'requests.exceptions.ConnectionError'>, <class 'requests.exceptions.RequestException'>, <class 'OSError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
|
|
||
| _RETRYABLE_TYPES = ( | ||
| ConnectionError, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Note that ConnectionError is not a stdlib type in Python 2.7:
$ .nox/unit-2-7/bin/python Python 2.7.17 (default, Apr 20 2021, 14:27:04) [GCC 9.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ConnectionError Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'ConnectionError' is not defined
We need to do something like:
try: _RETRYABLE_STDLIB_TYPES = {ConnectionError,) except NameError: _RETRYABLE_STDLIB_TYPES = {}
and then, below:
RETRYABLE_TYPES = _RETRYABLE_STDLIB_TYPES + ( api_exceptions.TooManyRequests, # 429 ... )
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@googlebot I fixed it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@googlebot I fixed it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@cojenco I don't know what the CLAbot is on about. As a Googler, I believe you can manually clear the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @tseaver! Manually added the cla label. I'm looking at my configs. So when I commited the suggestion directly on Github, the email logged was a <users.noreply.github.com> account. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ugh, I tested that syntax at the Python command prompt, where try: ConnectionError except NameError: _HAS_CONNECTION_ERROR = False else: _HAS_CONNECTION_ERROR = True and then use that flag to control the skip: @unittest.skipUnless(_HAS_CONNECTION_ERROR, "...")Since my suggestion didn't work out, and messed up the CLAbot, maybe it would be best to rebase away |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…444) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pre-commit/pre-commit-hooks](https://togithub.com/pre-commit/pre-commit-hooks) | repository | major | `v3.4.0` -> `v4.0.1` | --- ### Release Notes <details> <summary>pre-commit/pre-commit-hooks</summary> ### [`v4.0.1`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.1) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v4.0.0...v4.0.1) ##### Fixes - `check-shebang-scripts-are-executable` fix entry point. - [#​602](https://togithub.com/pre-commit/pre-commit-hooks/issues/602) issue by [@​Person-93](https://togithub.com/Person-93). - [#​603](https://togithub.com/pre-commit/pre-commit-hooks/issues/603) PR by [@​scop](https://togithub.com/scop). ### [`v4.0.0`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.0) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.0) ##### Features - `check-json`: report duplicate keys. - [#​558](https://togithub.com/pre-commit/pre-commit-hooks/issues/558) PR by [@​AdityaKhursale](https://togithub.com/AdityaKhursale). - [#​554](https://togithub.com/pre-commit/pre-commit-hooks/issues/554) issue by [@​adamchainz](https://togithub.com/adamchainz). - `no-commit-to-branch`: add `main` to default blocked branches. - [#​565](https://togithub.com/pre-commit/pre-commit-hooks/issues/565) PR by [@​ndevenish](https://togithub.com/ndevenish). - `check-case-conflict`: check conflicts in directory names as well. - [#​575](https://togithub.com/pre-commit/pre-commit-hooks/issues/575) PR by [@​slsyy](https://togithub.com/slsyy). - [#​70](https://togithub.com/pre-commit/pre-commit-hooks/issues/70) issue by [@​andyjack](https://togithub.com/andyjack). - `check-vcs-permalinks`: forbid other branch names. - [#​582](https://togithub.com/pre-commit/pre-commit-hooks/issues/582) PR by [@​jack1142](https://togithub.com/jack1142). - [#​581](https://togithub.com/pre-commit/pre-commit-hooks/issues/581) issue by [@​jack1142](https://togithub.com/jack1142). - `check-shebang-scripts-are-executable`: new hook which ensures shebang'd scripts are executable. - [#​545](https://togithub.com/pre-commit/pre-commit-hooks/issues/545) PR by [@​scop](https://togithub.com/scop). ##### Fixes - `check-executables-have-shebangs`: Short circuit shebang lookup on windows. - [#​544](https://togithub.com/pre-commit/pre-commit-hooks/issues/544) PR by [@​scop](https://togithub.com/scop). - `requirements-txt-fixer`: Fix comments which have indentation - [#​549](https://togithub.com/pre-commit/pre-commit-hooks/issues/549) PR by [@​greshilov](https://togithub.com/greshilov). - [#​548](https://togithub.com/pre-commit/pre-commit-hooks/issues/548) issue by [@​greshilov](https://togithub.com/greshilov). - `pretty-format-json`: write to stdout using UTF-8 encoding. - [#​571](https://togithub.com/pre-commit/pre-commit-hooks/issues/571) PR by [@​jack1142](https://togithub.com/jack1142). - [#​570](https://togithub.com/pre-commit/pre-commit-hooks/issues/570) issue by [@​jack1142](https://togithub.com/jack1142). - Use more inclusive language. - [#​599](https://togithub.com/pre-commit/pre-commit-hooks/issues/599) PR by [@​asottile](https://togithub.com/asottile). ##### Breaking changes - Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`. - [#​597](https://togithub.com/pre-commit/pre-commit-hooks/issues/597) PR by [@​asottile](https://togithub.com/asottile). </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/python-storage).
This adds python built-in [ConnectionError](https://docs.python.org/3/library/exceptions.html#ConnectionError) to default retryable types. ConnectionError was recently added in the [BigQuery library](googleapis/python-bigquery#571) to allow retries. Fixes googleapis#426 🦕
This adds python built-in [ConnectionError](https://docs.python.org/3/library/exceptions.html#ConnectionError) to default retryable types. ConnectionError was recently added in the [BigQuery library](googleapis/python-bigquery#571) to allow retries. Fixes googleapis#426 🦕
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Add Python ConnectionError in list of retry
There was an error while loading. Please reload this page.