Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Dec 11, 2023
1 parent 6a52214 commit a0b5975
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion google/cloud/bigtable/batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ def _flush_async(self):
self.flow_control.control_flow(batch_info)
future = self._executor.submit(self._flush_rows, rows_to_flush)
# schedule release of resources from flow control
future.add_done_callback(partial(self._batch_completed_callback, copy(batch_info)))
future.add_done_callback(
partial(self._batch_completed_callback, copy(batch_info))
)

def _batch_completed_callback(self, batch_info, future):
"""Callback for when the mutation has finished to clean up the current batch
Expand Down
15 changes: 12 additions & 3 deletions tests/system/test_data_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,21 @@ def callback(results):
assert results <= max_elements_per_batch

# override flow control max elements
with mock.patch("google.cloud.bigtable.batcher.MAX_OUTSTANDING_ELEMENTS", max_elements_per_batch):
with MutationsBatcher(data_table, flush_count=5, flush_interval=0.07, batch_completed_callback=callback) as batcher:
with mock.patch(
"google.cloud.bigtable.batcher.MAX_OUTSTANDING_ELEMENTS", max_elements_per_batch
):
with MutationsBatcher(
data_table,
flush_count=5,
flush_interval=0.07,
batch_completed_callback=callback,
) as batcher:
# send mutations in a way that timed flushes and count flushes interleave
for i in range(num_sent):
row = data_table.direct_row("row{}".format(i))
row.set_cell(COLUMN_FAMILY_ID1, COL_NAME1, "val{}".format(i).encode("utf-8"))
row.set_cell(
COLUMN_FAMILY_ID1, COL_NAME1, "val{}".format(i).encode("utf-8")
)
rows_to_delete.append(row)
batcher.mutate(row)
time.sleep(0.01)
Expand Down

0 comments on commit a0b5975

Please sign in to comment.