|
14 | 14 |
|
15 | 15 | """User-friendly container for Google Cloud Bigtable Table.""" |
16 | 16 |
|
17 | | -from grpc import StatusCode |
18 | | - |
19 | 17 | from google.api_core import timeout |
20 | | -from google.api_core.exceptions import RetryError |
| 18 | +from google.api_core.exceptions import Aborted |
| 19 | +from google.api_core.exceptions import DeadlineExceeded |
21 | 20 | from google.api_core.exceptions import NotFound |
| 21 | +from google.api_core.exceptions import RetryError |
| 22 | +from google.api_core.exceptions import ServiceUnavailable |
22 | 23 | from google.api_core.retry import if_exception_type |
23 | 24 | from google.api_core.retry import Retry |
24 | 25 | from google.api_core.gapic_v1.method import wrap_method |
@@ -986,15 +987,12 @@ class _RetryableMutateRowsWorker(object): |
986 | 987 | are retryable, any subsequent call on this callable will be a no-op. |
987 | 988 | """ |
988 | 989 |
|
989 | | - # pylint: disable=unsubscriptable-object |
990 | 990 | RETRY_CODES = ( |
991 | | - StatusCode.DEADLINE_EXCEEDED.value[0], |
992 | | - StatusCode.ABORTED.value[0], |
993 | | - StatusCode.UNAVAILABLE.value[0], |
| 991 | + Aborted.grpc_status_code.value[0], |
| 992 | + DeadlineExceeded.grpc_status_code.value[0], |
| 993 | + ServiceUnavailable.grpc_status_code.value[0], |
994 | 994 | ) |
995 | 995 |
|
996 | | - # pylint: enable=unsubscriptable-object |
997 | | - |
998 | 996 | def __init__(self, client, table_name, rows, app_profile_id=None, timeout=None): |
999 | 997 | self.client = client |
1000 | 998 | self.table_name = table_name |
@@ -1078,9 +1076,15 @@ def _do_mutate_retryable_rows(self): |
1078 | 1076 | client_info=data_client._client_info, |
1079 | 1077 | ) |
1080 | 1078 |
|
1081 | | - responses = data_client._inner_api_calls["mutate_rows"]( |
1082 | | - mutate_rows_request, retry=None |
1083 | | - ) |
| 1079 | + try: |
| 1080 | + responses = data_client._inner_api_calls["mutate_rows"]( |
| 1081 | + mutate_rows_request, retry=None |
| 1082 | + ) |
| 1083 | + except (ServiceUnavailable, DeadlineExceeded, Aborted): |
| 1084 | + # If an exception, considered retryable by `RETRY_CODES`, is |
| 1085 | + # returned from the initial call, consider |
| 1086 | + # it to be retryable. Wrap as a Bigtable Retryable Error. |
| 1087 | + raise _BigtableRetryableError |
1084 | 1088 |
|
1085 | 1089 | num_responses = 0 |
1086 | 1090 | num_retryable_responses = 0 |
|
0 commit comments