Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Classify 503 Service Unavailable errors as transient. #8182

Merged
merged 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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