From 3e021a46d387a0e3cb69913a281062fc221bb926 Mon Sep 17 00:00:00 2001 From: shollyman Date: Mon, 14 Aug 2023 09:15:45 -0700 Subject: [PATCH] feat: widen retry predicate to include ServiceUnavailable (#1641) 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 --- google/cloud/bigquery/retry.py | 1 + tests/unit/test_retry.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/google/cloud/bigquery/retry.py b/google/cloud/bigquery/retry.py index 254b26608..d0830ed13 100644 --- a/google/cloud/bigquery/retry.py +++ b/google/cloud/bigquery/retry.py @@ -27,6 +27,7 @@ exceptions.TooManyRequests, exceptions.InternalServerError, exceptions.BadGateway, + exceptions.ServiceUnavailable, requests.exceptions.ChunkedEncodingError, requests.exceptions.ConnectionError, requests.exceptions.Timeout, diff --git a/tests/unit/test_retry.py b/tests/unit/test_retry.py index e0a992f78..60d04de89 100644 --- a/tests/unit/test_retry.py +++ b/tests/unit/test_retry.py @@ -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))