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

Commit fa865cb

Browse files
committed
followed same operation management pattern for read_rows as mutate_rows
1 parent 98e4006 commit fa865cb

2 files changed

Lines changed: 34 additions & 35 deletions

File tree

google/cloud/bigtable/data/_async/_read_rows.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ def start_operation(self) -> CrossSync.Iterable[Row]:
118118
Yields:
119119
Row: The next row in the stream
120120
"""
121-
return CrossSync.retry_target_stream(
122-
self._read_rows_attempt,
123-
self._predicate,
124-
self._operation_metric.backoff_generator,
125-
self.operation_timeout,
126-
exception_factory=_retry_exception_factory,
127-
)
121+
with self._operation_metric:
122+
return CrossSync.retry_target_stream(
123+
self._read_rows_attempt,
124+
self._predicate,
125+
self._operation_metric.backoff_generator,
126+
self.operation_timeout,
127+
exception_factory=_retry_exception_factory,
128+
)
128129

129130
def _read_rows_attempt(self) -> CrossSync.Iterable[Row]:
130131
"""

google/cloud/bigtable/data/_async/client.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,18 +1020,17 @@ async def read_rows_stream(
10201020
)
10211021
retryable_excs = _get_retryable_errors(retryable_errors, self)
10221022

1023-
with self._metrics.create_operation(
1024-
OperationType.READ_ROWS, streaming=True
1025-
) as operation_metric:
1026-
row_merger = CrossSync._ReadRowsOperation(
1027-
query,
1028-
self,
1029-
operation_timeout=operation_timeout,
1030-
attempt_timeout=attempt_timeout,
1031-
metric=operation_metric,
1032-
retryable_exceptions=retryable_excs,
1033-
)
1034-
return row_merger.start_operation()
1023+
row_merger = CrossSync._ReadRowsOperation(
1024+
query,
1025+
self,
1026+
operation_timeout=operation_timeout,
1027+
attempt_timeout=attempt_timeout,
1028+
metric=self._metrics.create_operation(
1029+
OperationType.READ_ROWS, streaming=True
1030+
),
1031+
retryable_exceptions=retryable_excs,
1032+
)
1033+
return row_merger.start_operation()
10351034

10361035
@CrossSync.convert
10371036
async def read_rows(
@@ -1129,22 +1128,21 @@ async def read_row(
11291128
)
11301129
retryable_excs = _get_retryable_errors(retryable_errors, self)
11311130

1132-
with self._metrics.create_operation(
1133-
OperationType.READ_ROWS, streaming=False
1134-
) as operation_metric:
1135-
row_merger = CrossSync._ReadRowsOperation(
1136-
query,
1137-
self,
1138-
operation_timeout=operation_timeout,
1139-
attempt_timeout=attempt_timeout,
1140-
metric=operation_metric,
1141-
retryable_exceptions=retryable_excs,
1142-
)
1143-
results_generator = row_merger.start_operation()
1144-
try:
1145-
return results_generator.__anext__()
1146-
except StopAsyncIteration:
1147-
return None
1131+
row_merger = CrossSync._ReadRowsOperation(
1132+
query,
1133+
self,
1134+
operation_timeout=operation_timeout,
1135+
attempt_timeout=attempt_timeout,
1136+
metric=self._metrics.create_operation(
1137+
OperationType.READ_ROWS, streaming=False
1138+
),
1139+
retryable_exceptions=retryable_excs,
1140+
)
1141+
results_generator = row_merger.start_operation()
1142+
try:
1143+
return results_generator.__anext__()
1144+
except StopAsyncIteration:
1145+
return None
11481146

11491147
@CrossSync.convert
11501148
async def read_rows_sharded(

0 commit comments

Comments
 (0)