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

Commit 680f952

Browse files
committed
Slightly simplify bits of page streaming logic
1 parent 7739a5f commit 680f952

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

google/cloud/bigquery/_pandas_helpers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,12 @@ def _download_table_bqstorage(
703703
continue
704704

705705
# Return any remaining values after the workers finished.
706-
while not worker_queue.empty(): # pragma: NO COVER
706+
while True: # pragma: NO COVER
707707
try:
708-
# Include a timeout because even though the queue is
709-
# non-empty, it doesn't guarantee that a subsequent call to
710-
# get() will not block.
711-
frame = worker_queue.get(timeout=_PROGRESS_INTERVAL)
708+
frame = worker_queue.get_nowait()
712709
yield frame
713710
except queue.Empty: # pragma: NO COVER
714-
continue
711+
break
715712
finally:
716713
# No need for a lock because reading/replacing a variable is
717714
# defined to be an atomic operation in the Python language

google/cloud/bigquery/table.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,13 +1490,12 @@ def _to_page_iterable(
14901490
if not self._validate_bqstorage(bqstorage_client, False):
14911491
bqstorage_client = None
14921492

1493-
if bqstorage_client is not None:
1494-
for item in bqstorage_download():
1495-
yield item
1496-
return
1497-
1498-
for item in tabledata_list_download():
1499-
yield item
1493+
result_pages = (
1494+
bqstorage_download()
1495+
if bqstorage_client is not None
1496+
else tabledata_list_download()
1497+
)
1498+
yield from result_pages
15001499

15011500
def _to_arrow_iterable(
15021501
self,

0 commit comments

Comments
 (0)