Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ae04a8

Browse files
authored
feat: retry google.auth TransportError and requests ConnectionError (#178)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:- [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-api-core/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea- [x] Ensure the tests and linter pass- [x] Code coverage does not decrease (if any source code was changed)- [x] Appropriate docs were updated (if necessary)Fixes#176 🦕
1 parentf87bccb commit6ae04a8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎google/api_core/retry.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ def check_if_exists():
6262
importrandom
6363
importtime
6464

65+
importrequests.exceptions
6566
importsix
6667

6768
fromgoogle.api_coreimportdatetime_helpers
6869
fromgoogle.api_coreimportexceptions
6970
fromgoogle.api_coreimportgeneral_helpers
71+
fromgoogle.authimportexceptionsasauth_exceptions
7072

7173
_LOGGER=logging.getLogger(__name__)
7274
_DEFAULT_INITIAL_DELAY=1.0# seconds
@@ -101,6 +103,8 @@ def if_exception_type_predicate(exception):
101103
exceptions.InternalServerError,
102104
exceptions.TooManyRequests,
103105
exceptions.ServiceUnavailable,
106+
requests.exceptions.ConnectionError,
107+
auth_exceptions.TransportError,
104108
)
105109
"""A predicate that checks if an exception is a transient API error.
106110

‎tests/unit/test_retry.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
importmock
2020
importpytest
21+
importrequests.exceptions
2122

2223
fromgoogle.api_coreimportexceptions
2324
fromgoogle.api_coreimportretry
25+
fromgoogle.authimportexceptionsasauth_exceptions
2426

2527

2628
deftest_if_exception_type():
@@ -42,6 +44,8 @@ def test_if_transient_error():
4244
assertretry.if_transient_error(exceptions.InternalServerError(""))
4345
assertretry.if_transient_error(exceptions.TooManyRequests(""))
4446
assertretry.if_transient_error(exceptions.ServiceUnavailable(""))
47+
assertretry.if_transient_error(requests.exceptions.ConnectionError(""))
48+
assertretry.if_transient_error(auth_exceptions.TransportError(""))
4549
assertnotretry.if_transient_error(exceptions.InvalidArgument(""))
4650

4751

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp