Skip to content

Commit

Permalink
feat: widen retry predicate to include ServiceUnavailable (#1641)
Browse files Browse the repository at this point in the history
Expands retry.  It's possible in the normal lifecycle of an API frontend
for the intermediate response to indicate the API service is not ready.

related: internal issue 294103068
  • Loading branch information
shollyman committed Aug 14, 2023
1 parent b0199f2 commit 3e021a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions google/cloud/bigquery/retry.py
Expand Up @@ -27,6 +27,7 @@
exceptions.TooManyRequests,
exceptions.InternalServerError,
exceptions.BadGateway,
exceptions.ServiceUnavailable,
requests.exceptions.ChunkedEncodingError,
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_retry.py
Expand Up @@ -79,6 +79,12 @@ def test_w_unstructured_too_many_requests(self):
exc = TooManyRequests("testing")
self.assertTrue(self._call_fut(exc))

def test_w_unstructured_service_unavailable(self):
from google.api_core.exceptions import ServiceUnavailable

exc = ServiceUnavailable("testing")
self.assertTrue(self._call_fut(exc))

def test_w_internalError(self):
exc = mock.Mock(errors=[{"reason": "internalError"}], spec=["errors"])
self.assertTrue(self._call_fut(exc))
Expand Down

0 comments on commit 3e021a4

Please sign in to comment.