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

Commit f0ff168

Browse files
committed
improved grace period handling
1 parent 045900a commit f0ff168

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,8 @@ async def _manage_channel(
480480
old_channel = super_channel.swap_channel(new_channel)
481481
self._invalidate_channel_stubs()
482482
# give old_channel a chance to complete existing rpcs
483-
if CrossSync.is_async:
484-
await old_channel.close(grace_period)
485-
else:
486-
if grace_period:
487-
self._is_closed.wait(grace_period) # type: ignore
488-
old_channel.close() # type: ignore
483+
await CrossSync.event_wait(self._is_closed, grace_period, async_break_early=False)
484+
await old_channel.close()
489485
# subtract the time spent waiting for the channel to be replaced
490486
next_refresh = random.uniform(refresh_interval_min, refresh_interval_max)
491487
next_sleep = max(next_refresh - (time.monotonic() - start_timestamp), 0)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ def _manage_channel(
363363
self._ping_and_warm_instances(channel=new_channel)
364364
old_channel = super_channel.swap_channel(new_channel)
365365
self._invalidate_channel_stubs()
366-
if grace_period:
367-
self._is_closed.wait(grace_period)
366+
CrossSync._Sync_Impl.event_wait(
367+
self._is_closed, grace_period, async_break_early=False
368+
)
368369
old_channel.close()
369370
next_refresh = random.uniform(refresh_interval_min, refresh_interval_max)
370371
next_sleep = max(next_refresh - (time.monotonic() - start_timestamp), 0)

0 commit comments

Comments
 (0)