Skip to content

Commit 3f8bd10

Browse files
committed
fix: avoid blocking in download thread when using BQ Storage API
This prevents a deadlock between the main thead and download threads when the threadpool is shutdown prematurely.
1 parent 7372ad6 commit 3f8bd10

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

google/cloud/bigquery/_pandas_helpers.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,15 @@ def _download_table_bqstorage_stream(
796796
rowstream = reader.rows(session)
797797

798798
for page in rowstream.pages:
799-
if download_state.done:
800-
return
801799
item = page_to_item(page)
802-
worker_queue.put(item)
800+
while True:
801+
if download_state.done:
802+
return
803+
try:
804+
worker_queue.put(item, timeout=_PROGRESS_INTERVAL)
805+
break
806+
except queue.Full: # pragma: NO COVER
807+
continue
803808

804809

805810
def _nowait(futures):

0 commit comments

Comments
 (0)