From 3ed343779214ed43cc7a1459f01fe021599767ea Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 25 Nov 2026 18:33:47 -0700 Subject: [PATCH 1/3] wait on flush timer --- .../tests/unit/data/_async/test_mutations_batcher.py | 6 +++--- .../tests/unit/data/_sync_autogen/test_mutations_batcher.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/google-cloud-bigtable/tests/unit/data/_async/test_mutations_batcher.py b/packages/google-cloud-bigtable/tests/unit/data/_async/test_mutations_batcher.py index b144a1bbeb0c..22780004f82d 100644 --- a/packages/google-cloud-bigtable/tests/unit/data/_async/test_mutations_batcher.py +++ b/packages/google-cloud-bigtable/tests/unit/data/_async/test_mutations_batcher.py @@ -405,7 +405,7 @@ async def test_ctor_defaults(self): instance._retryable_errors == table.default_mutate_rows_retryable_errors ) - await CrossSync.yield_to_event_loop() + await CrossSync.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] == 5 assert isinstance(instance._flush_timer, CrossSync.Future) @@ -457,7 +457,7 @@ async def test_ctor_explicit(self): assert instance._operation_timeout == operation_timeout assert instance._attempt_timeout == attempt_timeout assert instance._retryable_errors == retryable_errors - await CrossSync.yield_to_event_loop() + await CrossSync.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] == flush_interval assert isinstance(instance._flush_timer, CrossSync.Future) @@ -491,7 +491,7 @@ async def test_ctor_no_flush_limits(self): assert instance._flow_control._in_flight_mutation_count == 0 assert instance._flow_control._in_flight_mutation_bytes == 0 assert instance._entries_processed_since_last_raise == 0 - await CrossSync.yield_to_event_loop() + await CrossSync.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] is None assert isinstance(instance._flush_timer, CrossSync.Future) diff --git a/packages/google-cloud-bigtable/tests/unit/data/_sync_autogen/test_mutations_batcher.py b/packages/google-cloud-bigtable/tests/unit/data/_sync_autogen/test_mutations_batcher.py index d67a7623789e..4349c39c7bb8 100644 --- a/packages/google-cloud-bigtable/tests/unit/data/_sync_autogen/test_mutations_batcher.py +++ b/packages/google-cloud-bigtable/tests/unit/data/_sync_autogen/test_mutations_batcher.py @@ -353,7 +353,7 @@ def test_ctor_defaults(self): instance._retryable_errors == table.default_mutate_rows_retryable_errors ) - CrossSync._Sync_Impl.yield_to_event_loop() + CrossSync._Sync_Impl.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] == 5 assert isinstance(instance._flush_timer, CrossSync._Sync_Impl.Future) @@ -406,7 +406,7 @@ def test_ctor_explicit(self): assert instance._operation_timeout == operation_timeout assert instance._attempt_timeout == attempt_timeout assert instance._retryable_errors == retryable_errors - CrossSync._Sync_Impl.yield_to_event_loop() + CrossSync._Sync_Impl.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] == flush_interval assert isinstance(instance._flush_timer, CrossSync._Sync_Impl.Future) @@ -441,7 +441,7 @@ def test_ctor_no_flush_limits(self): assert instance._flow_control._in_flight_mutation_count == 0 assert instance._flow_control._in_flight_mutation_bytes == 0 assert instance._entries_processed_since_last_raise == 0 - CrossSync._Sync_Impl.yield_to_event_loop() + CrossSync._Sync_Impl.wait([instance._flush_timer]) assert flush_timer_mock.call_count == 1 assert flush_timer_mock.call_args[0][0] is None assert isinstance(instance._flush_timer, CrossSync._Sync_Impl.Future) From 2e0270893e4c89caeaa78b02d027cdbd883b2260 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 25 Nov 2026 18:37:26 -0700 Subject: [PATCH 2/3] wait for table creation --- .../samples/data_client/hello/main.py | 11 +++++++++++ .../samples/data_client_async/hello/async_main.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/google-cloud-bigtable/samples/data_client/hello/main.py b/packages/google-cloud-bigtable/samples/data_client/hello/main.py index b317b35ec336..adfecfb5464f 100644 --- a/packages/google-cloud-bigtable/samples/data_client/hello/main.py +++ b/packages/google-cloud-bigtable/samples/data_client/hello/main.py @@ -72,6 +72,17 @@ def main(project_id, instance_id, table_id): # [END bigtable_hw_create_table] try: + # Wait for table creation to propagate to the data plane. + from google.api_core.exceptions import FailedPrecondition + + table.read_row( + b"greeting0", + operation_timeout=120, + retryable_errors=( + *table.default_read_rows_retryable_errors, + FailedPrecondition, + ), + ) # [START bigtable_hw_write_rows] print("Writing some greetings to the table.") greetings = [b"Hello World!", b"Hello Cloud Bigtable!", b"Hello Python!"] diff --git a/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py b/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py index 46c91a2358c9..d9a6f05bdca1 100644 --- a/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py +++ b/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py @@ -72,6 +72,17 @@ async def main(project_id, instance_id, table_id): # [END bigtable_async_hw_create_table] try: + # Wait for table creation to propagate to the data plane. + from google.api_core.exceptions import FailedPrecondition + + await table.read_row( + b"greeting0", + operation_timeout=120, + retryable_errors=( + *table.default_read_rows_retryable_errors, + FailedPrecondition, + ), + ) # [START bigtable_async_hw_write_rows] print("Writing some greetings to the table.") greetings = [b"Hello World!", b"Hello Cloud Bigtable!", b"Hello Python!"] From 7eb7877d71b4ff5f35f7ed70bee8cfb42d5cafe8 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 25 Nov 2026 18:49:05 -0700 Subject: [PATCH 3/3] add not found to retryable list --- .../google-cloud-bigtable/samples/data_client/hello/main.py | 3 ++- .../samples/data_client_async/hello/async_main.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-bigtable/samples/data_client/hello/main.py b/packages/google-cloud-bigtable/samples/data_client/hello/main.py index adfecfb5464f..89a14904f99d 100644 --- a/packages/google-cloud-bigtable/samples/data_client/hello/main.py +++ b/packages/google-cloud-bigtable/samples/data_client/hello/main.py @@ -73,7 +73,7 @@ def main(project_id, instance_id, table_id): try: # Wait for table creation to propagate to the data plane. - from google.api_core.exceptions import FailedPrecondition + from google.api_core.exceptions import FailedPrecondition, NotFound table.read_row( b"greeting0", @@ -81,6 +81,7 @@ def main(project_id, instance_id, table_id): retryable_errors=( *table.default_read_rows_retryable_errors, FailedPrecondition, + NotFound, ), ) # [START bigtable_hw_write_rows] diff --git a/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py b/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py index d9a6f05bdca1..efdd7191e311 100644 --- a/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py +++ b/packages/google-cloud-bigtable/samples/data_client_async/hello/async_main.py @@ -73,7 +73,7 @@ async def main(project_id, instance_id, table_id): try: # Wait for table creation to propagate to the data plane. - from google.api_core.exceptions import FailedPrecondition + from google.api_core.exceptions import FailedPrecondition, NotFound await table.read_row( b"greeting0", @@ -81,6 +81,7 @@ async def main(project_id, instance_id, table_id): retryable_errors=( *table.default_read_rows_retryable_errors, FailedPrecondition, + NotFound, ), ) # [START bigtable_async_hw_write_rows]