diff --git a/api_core/google/api_core/retry.py b/api_core/google/api_core/retry.py index 96d9f23f25b8..028af3ecfb41 100644 --- a/api_core/google/api_core/retry.py +++ b/api_core/google/api_core/retry.py @@ -98,7 +98,9 @@ def if_exception_type_predicate(exception): # 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 @@ def if_exception_type_predicate(exception): - :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/api_core/setup.py b/api_core/setup.py index a82cf0e0b077..d1374500b05b 100644 --- a/api_core/setup.py +++ b/api_core/setup.py @@ -39,7 +39,7 @@ '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/api_core/tests/unit/test_retry.py b/api_core/tests/unit/test_retry.py index 013b6ad87b04..53c239620c68 100644 --- a/api_core/tests/unit/test_retry.py +++ b/api_core/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("")) diff --git a/core/setup.py b/core/setup.py index 761f5f2e4ad1..99314193867b 100644 --- a/core/setup.py +++ b/core/setup.py @@ -29,7 +29,7 @@ # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 4 - Beta" dependencies = ["google-api-core >= 1.11.0, < 2.0.0dev"] -extras = {"grpc": "grpcio >= 1.8.2"} +extras = {"grpc": "grpcio >= 1.8.2, < 2.0dev"} # Setup boilerplate below this line.