2323from google .cloud .bigtable .data .mutations import RowMutationEntry
2424from google .cloud .bigtable .data .exceptions import MutationsExceptionGroup
2525from google .cloud .bigtable .data .exceptions import FailedMutationEntryError
26+ from google .cloud .bigtable .data ._helpers import _validate_timeouts
2627
2728from google .cloud .bigtable .data ._async ._mutate_rows import _MutateRowsOperationAsync
2829from google .cloud .bigtable .data ._async ._mutate_rows import (
@@ -189,7 +190,7 @@ def __init__(
189190 flow_control_max_mutation_count : int = 100_000 ,
190191 flow_control_max_bytes : int = 100 * _MB_SIZE ,
191192 batch_operation_timeout : float | None = None ,
192- batch_per_request_timeout : float | None = None ,
193+ batch_attempt_timeout : float | None = None ,
193194 ):
194195 """
195196 Args:
@@ -202,26 +203,20 @@ def __init__(
202203 - flow_control_max_mutation_count: Maximum number of inflight mutations.
203204 - flow_control_max_bytes: Maximum number of inflight bytes.
204205 - batch_operation_timeout: timeout for each mutate_rows operation, in seconds. If None,
205- table default_operation_timeout will be used
206- - batch_per_request_timeout: timeout for each individual request, in seconds. If None,
207- table default_per_request_timeout will be used
206+ table default_mutate_rows_operation_timeout will be used
207+ - batch_attempt_timeout: timeout for each individual request, in seconds. If None,
208+ table default_mutate_rows_attempt_timeout will be used, or batch_operation_timeout
209+ if that is also None.
208210 """
209211 self ._operation_timeout : float = (
210- batch_operation_timeout or table .default_operation_timeout
212+ batch_operation_timeout or table .default_mutate_rows_operation_timeout
211213 )
212- self ._per_request_timeout : float = (
213- batch_per_request_timeout
214- or table .default_per_request_timeout
214+ self ._attempt_timeout : float = (
215+ batch_attempt_timeout
216+ or table .default_mutate_rows_attempt_timeout
215217 or self ._operation_timeout
216218 )
217- if self ._operation_timeout <= 0 :
218- raise ValueError ("batch_operation_timeout must be greater than 0" )
219- if self ._per_request_timeout <= 0 :
220- raise ValueError ("batch_per_request_timeout must be greater than 0" )
221- if self ._per_request_timeout > self ._operation_timeout :
222- raise ValueError (
223- "batch_per_request_timeout must be less than batch_operation_timeout"
224- )
219+ _validate_timeouts (self ._operation_timeout , self ._attempt_timeout )
225220 self .closed : bool = False
226221 self ._table = table
227222 self ._staged_entries : list [RowMutationEntry ] = []
@@ -346,7 +341,7 @@ async def _execute_mutate_rows(
346341
347342 Args:
348343 - batch: list of RowMutationEntry objects to send to server
349- - timeout: timeout in seconds. Used as operation_timeout and per_request_timeout .
344+ - timeout: timeout in seconds. Used as operation_timeout and attempt_timeout .
350345 If not given, will use table defaults
351346 Returns:
352347 - list of FailedMutationEntryError objects for mutations that failed.
@@ -361,7 +356,7 @@ async def _execute_mutate_rows(
361356 self ._table ,
362357 batch ,
363358 operation_timeout = self ._operation_timeout ,
364- per_request_timeout = self ._per_request_timeout ,
359+ attempt_timeout = self ._attempt_timeout ,
365360 )
366361 await operation .start ()
367362 except MutationsExceptionGroup as e :
0 commit comments