Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions google/cloud/bigtable/batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class MutationsBatcher(object):
:type flush_interval: float
:param flush_interval: (Optional) The interval (in seconds) between asynchronous flush.
Default is 1 second.

:type flush_completed_callback: Callable = None
:param flush_completed_callback: (Optional) A callable funtion for handling responses
Comment thread
mutianf marked this conversation as resolved.
Outdated
after the request is flushed.
"""

def __init__(
Expand All @@ -200,6 +204,7 @@ def __init__(
flush_count=FLUSH_COUNT,
max_row_bytes=MAX_MUTATION_SIZE,
flush_interval=1,
flush_completed_callback=None,
):
self._rows = _MutationsBatchQueue(
max_mutation_bytes=max_row_bytes, flush_count=flush_count
Expand All @@ -215,6 +220,7 @@ def __init__(
)
self.futures_mapping = {}
self.exceptions = queue.Queue()
self.flush_completed_callback = flush_completed_callback
Comment thread
mutianf marked this conversation as resolved.
Outdated

@property
def flush_count(self):
Expand Down Expand Up @@ -357,6 +363,9 @@ def _flush_rows(self, rows_to_flush):
if len(rows_to_flush) > 0:
response = self.table.mutate_rows(rows_to_flush)

if self.flush_completed_callback:
self.flush(response)
Comment thread
mutianf marked this conversation as resolved.
Outdated

for result in response:
if result.code != 0:
exc = from_grpc_status(result.code, result.message)
Expand Down