Skip to content

Commit

Permalink
Core: Classify 503 Service Unavailable errors as transient. (#8182)
Browse files Browse the repository at this point in the history
Also, pin grpcio < 2.0dev.

Closes #5410.
  • Loading branch information
tseaver authored May 28, 2019
1 parent f3d014c commit 372153c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion api_core/google/api_core/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)``
"""
Expand Down
2 changes: 1 addition & 1 deletion api_core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
1 change: 1 addition & 0 deletions api_core/tests/unit/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(""))


Expand Down
2 changes: 1 addition & 1 deletion core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 372153c

Please sign in to comment.