|
23 | 23 | import warnings |
24 | 24 |
|
25 | 25 | from google.api_core.client_options import ClientOptions |
26 | | -from google.api_core.retry import Retry, if_exception_type |
| 26 | +from google.api_core.retry import if_exception_type |
27 | 27 | import google.auth.credentials |
28 | 28 | from google.protobuf.struct_pb2 import Struct |
29 | 29 | from google.cloud.exceptions import NotFound |
@@ -468,8 +468,9 @@ def execute_pdml(): |
468 | 468 |
|
469 | 469 | return result_set.stats.row_count_lower_bound |
470 | 470 |
|
471 | | - retry = Retry(predicate=if_exception_type(Aborted)) |
472 | | - return retry(execute_pdml)() |
| 471 | + retry_config = api._method_configs["ExecuteStreamingSql"].retry |
| 472 | + |
| 473 | + return _retry_on_aborted(execute_pdml, retry_config)() |
473 | 474 |
|
474 | 475 | def session(self, labels=None): |
475 | 476 | """Factory to create a session for this database. |
@@ -1029,3 +1030,19 @@ def __init__(self, source_type, backup_info): |
1029 | 1030 | @classmethod |
1030 | 1031 | def from_pb(cls, pb): |
1031 | 1032 | return cls(pb.source_type, pb.backup_info) |
| 1033 | + |
| 1034 | + |
| 1035 | +def _retry_on_aborted(func, retry_config): |
| 1036 | + """Helper for :meth:`Database.execute_partitioned_dml`. |
| 1037 | +
|
| 1038 | + Wrap function in a Retry that will retry on Aborted exceptions |
| 1039 | + with the retry config specified. |
| 1040 | +
|
| 1041 | + :type func: callable |
| 1042 | + :param func: the function to be retried on Aborted exceptions |
| 1043 | +
|
| 1044 | + :type retry_config: Retry |
| 1045 | + :param retry_config: retry object with the settings to be used |
| 1046 | + """ |
| 1047 | + retry = retry_config.with_predicate(if_exception_type(Aborted)) |
| 1048 | + return retry(func) |
0 commit comments