-
Notifications
You must be signed in to change notification settings - Fork 156
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
fix: add ConnectionError to default retry #445
Conversation
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.
thanks!
google/cloud/storage/retry.py
Outdated
@@ -22,6 +22,7 @@ | |||
|
|||
|
|||
_RETRYABLE_TYPES = ( | |||
ConnectionError, |
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.
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?
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.
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'>)
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.
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
...
)
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.
@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!
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.
@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!
google/cloud/storage/retry.py
Outdated
@@ -22,6 +22,7 @@ | |||
|
|||
|
|||
_RETRYABLE_TYPES = ( | |||
ConnectionError, |
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.
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'>)
google/cloud/storage/retry.py
Outdated
@@ -22,6 +22,7 @@ | |||
|
|||
|
|||
_RETRYABLE_TYPES = ( | |||
ConnectionError, |
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.
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
...
)
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. |
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. |
@googlebot I fixed it. |
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. |
@googlebot I fixed it. |
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. |
@cojenco I don't know what the CLAbot is on about. As a Googler, I believe you can manually clear the |
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. |
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 |
…444) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pre-commit/pre-commit-hooks](https://github.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://github.com/pre-commit/pre-commit-hooks/releases/v4.0.1) [Compare Source](https://github.com/pre-commit/pre-commit-hooks/compare/v4.0.0...v4.0.1) ##### Fixes - `check-shebang-scripts-are-executable` fix entry point. - [#​602](https://github.com/pre-commit/pre-commit-hooks/issues/602) issue by [@​Person-93](https://github.com/Person-93). - [#​603](https://github.com/pre-commit/pre-commit-hooks/issues/603) PR by [@​scop](https://github.com/scop). ### [`v4.0.0`](https://github.com/pre-commit/pre-commit-hooks/releases/v4.0.0) [Compare Source](https://github.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.0) ##### Features - `check-json`: report duplicate keys. - [#​558](https://github.com/pre-commit/pre-commit-hooks/issues/558) PR by [@​AdityaKhursale](https://github.com/AdityaKhursale). - [#​554](https://github.com/pre-commit/pre-commit-hooks/issues/554) issue by [@​adamchainz](https://github.com/adamchainz). - `no-commit-to-branch`: add `main` to default blocked branches. - [#​565](https://github.com/pre-commit/pre-commit-hooks/issues/565) PR by [@​ndevenish](https://github.com/ndevenish). - `check-case-conflict`: check conflicts in directory names as well. - [#​575](https://github.com/pre-commit/pre-commit-hooks/issues/575) PR by [@​slsyy](https://github.com/slsyy). - [#​70](https://github.com/pre-commit/pre-commit-hooks/issues/70) issue by [@​andyjack](https://github.com/andyjack). - `check-vcs-permalinks`: forbid other branch names. - [#​582](https://github.com/pre-commit/pre-commit-hooks/issues/582) PR by [@​jack1142](https://github.com/jack1142). - [#​581](https://github.com/pre-commit/pre-commit-hooks/issues/581) issue by [@​jack1142](https://github.com/jack1142). - `check-shebang-scripts-are-executable`: new hook which ensures shebang'd scripts are executable. - [#​545](https://github.com/pre-commit/pre-commit-hooks/issues/545) PR by [@​scop](https://github.com/scop). ##### Fixes - `check-executables-have-shebangs`: Short circuit shebang lookup on windows. - [#​544](https://github.com/pre-commit/pre-commit-hooks/issues/544) PR by [@​scop](https://github.com/scop). - `requirements-txt-fixer`: Fix comments which have indentation - [#​549](https://github.com/pre-commit/pre-commit-hooks/issues/549) PR by [@​greshilov](https://github.com/greshilov). - [#​548](https://github.com/pre-commit/pre-commit-hooks/issues/548) issue by [@​greshilov](https://github.com/greshilov). - `pretty-format-json`: write to stdout using UTF-8 encoding. - [#​571](https://github.com/pre-commit/pre-commit-hooks/issues/571) PR by [@​jack1142](https://github.com/jack1142). - [#​570](https://github.com/pre-commit/pre-commit-hooks/issues/570) issue by [@​jack1142](https://github.com/jack1142). - Use more inclusive language. - [#​599](https://github.com/pre-commit/pre-commit-hooks/issues/599) PR by [@​asottile](https://github.com/asottile). ##### Breaking changes - Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`. - [#​597](https://github.com/pre-commit/pre-commit-hooks/issues/597) PR by [@​asottile](https://github.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 🦕
This adds python built-in ConnectionError to default retryable types.
ConnectionError was recently added in the BigQuery library to allow retries.
Fixes #426 🦕