Skip to content

Commit 8c415c7

Browse files
authored
Core: Classify 503 Service Unavailable errors as transient. (#8182)
Also, pin grpcio < 2.0dev. Closes #5410.
1 parent 49f2ef5 commit 8c415c7

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

google/api_core/retry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def if_exception_type_predicate(exception):
9898
# Pylint sees this as a constant, but it is also an alias that should be
9999
# considered a function.
100100
if_transient_error = if_exception_type(
101-
(exceptions.InternalServerError, exceptions.TooManyRequests)
101+
exceptions.InternalServerError,
102+
exceptions.TooManyRequests,
103+
exceptions.ServiceUnavailable,
102104
)
103105
"""A predicate that checks if an exception is a transient API error.
104106
@@ -107,6 +109,7 @@ def if_exception_type_predicate(exception):
107109
- :class:`google.api_core.exceptions.InternalServerError` - HTTP 500, gRPC
108110
``INTERNAL(13)`` and its subclasses.
109111
- :class:`google.api_core.exceptions.TooManyRequests` - HTTP 429
112+
- :class:`google.api_core.exceptions.ServiceUnavailable` - HTTP 503
110113
- :class:`google.api_core.exceptions.ResourceExhausted` - gRPC
111114
``RESOURCE_EXHAUSTED(8)``
112115
"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'futures >= 3.2.0; python_version < "3.2"',
4040
]
4141
extras = {
42-
"grpc": "grpcio >= 1.8.2",
42+
"grpc": "grpcio >= 1.8.2, < 2.0dev",
4343
"grpcgcp": "grpcio-gcp >= 0.2.2",
4444
"grpcio-gcp": "grpcio-gcp >= 0.2.2",
4545
}

tests/unit/test_retry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def test_if_exception_type_multiple():
4141
def test_if_transient_error():
4242
assert retry.if_transient_error(exceptions.InternalServerError(""))
4343
assert retry.if_transient_error(exceptions.TooManyRequests(""))
44+
assert retry.if_transient_error(exceptions.ServiceUnavailable(""))
4445
assert not retry.if_transient_error(exceptions.InvalidArgument(""))
4546

4647

0 commit comments

Comments
 (0)