Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit e2cdef7

Browse files
authored
Add 'internalError' to retryable error reasons. (#5599)
Closes #5547.
1 parent b7d85cb commit e2cdef7

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

google/cloud/bigquery/retry.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
from google.api_core import retry
1717

1818

19+
_RETRYABLE_REASONS = frozenset([
20+
'backendError',
21+
'rateLimitExceeded',
22+
'internalError',
23+
])
24+
25+
1926
def _should_retry(exc):
2027
"""Predicate for determining when to retry.
2128
@@ -27,7 +34,7 @@ def _should_retry(exc):
2734
if len(exc.errors) == 0:
2835
return False
2936
reason = exc.errors[0]['reason']
30-
return reason == 'backendError' or reason == 'rateLimitExceeded'
37+
return reason in _RETRYABLE_REASONS
3138

3239

3340
DEFAULT_RETRY = retry.Retry(predicate=_should_retry)

tests/unit/test_retry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ def test_w_rateLimitExceeded(self):
4646
exc = mock.Mock(
4747
errors=[{'reason': 'rateLimitExceeded'}], spec=['errors'])
4848
self.assertTrue(self._call_fut(exc))
49+
50+
def test_w_internalError(self):
51+
exc = mock.Mock(
52+
errors=[{'reason': 'internalError'}], spec=['errors'])
53+
self.assertTrue(self._call_fut(exc))

0 commit comments

Comments
 (0)