aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--google/api_core/retry.py5
-rw-r--r--setup.py2
-rw-r--r--tests/unit/test_retry.py1
3 files changed, 6 insertions, 2 deletions
diff --git a/google/api_core/retry.py b/google/api_core/retry.py
index 96d9f23..028af3e 100644
--- a/google/api_core/retry.py
+++ b/google/api_core/retry.py
@@ -98,7 +98,9 @@ def if_exception_type(*exception_types):
# Pylint sees this as a constant, but it is also an alias that should be
# considered a function.
if_transient_error = if_exception_type(
- (exceptions.InternalServerError, exceptions.TooManyRequests)
+ exceptions.InternalServerError,
+ exceptions.TooManyRequests,
+ exceptions.ServiceUnavailable,
)
"""A predicate that checks if an exception is a transient API error.
@@ -107,6 +109,7 @@ The following server errors are considered transient:
- :class:`google.api_core.exceptions.InternalServerError` - HTTP 500, gRPC
``INTERNAL(13)`` and its subclasses.
- :class:`google.api_core.exceptions.TooManyRequests` - HTTP 429
+- :class:`google.api_core.exceptions.ServiceUnavailable` - HTTP 503
- :class:`google.api_core.exceptions.ResourceExhausted` - gRPC
``RESOURCE_EXHAUSTED(8)``
"""
diff --git a/setup.py b/setup.py
index a82cf0e..d137450 100644
--- a/setup.py
+++ b/setup.py
@@ -39,7 +39,7 @@ dependencies = [
'futures >= 3.2.0; python_version < "3.2"',
]
extras = {
- "grpc": "grpcio >= 1.8.2",
+ "grpc": "grpcio >= 1.8.2, < 2.0dev",
"grpcgcp": "grpcio-gcp >= 0.2.2",
"grpcio-gcp": "grpcio-gcp >= 0.2.2",
}
diff --git a/tests/unit/test_retry.py b/tests/unit/test_retry.py
index 013b6ad..53c2396 100644
--- a/tests/unit/test_retry.py
+++ b/tests/unit/test_retry.py
@@ -41,6 +41,7 @@ def test_if_exception_type_multiple():
def test_if_transient_error():
assert retry.if_transient_error(exceptions.InternalServerError(""))
assert retry.if_transient_error(exceptions.TooManyRequests(""))
+ assert retry.if_transient_error(exceptions.ServiceUnavailable(""))
assert not retry.if_transient_error(exceptions.InvalidArgument(""))