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

Commit f17c2d7

Browse files
fix closure bug, use as_completed instead of wait
1 parent 59ed1a8 commit f17c2d7

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

bigframes/session/bq_caching_executor.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from bigframes import exceptions as bfe
3030
import bigframes.constants
3131
import bigframes.core
32-
from bigframes.core import bq_data, compile, rewrite
32+
from bigframes.core import bq_data, compile, local_data, rewrite
3333
from bigframes.core.compile.sqlglot import sql as sg_sql
3434
from bigframes.core.compile.sqlglot import sqlglot_ir
3535
import bigframes.core.events
@@ -525,19 +525,21 @@ def _substitute_large_local_sources(self, original_root: nodes.BigFrameNode):
525525
needs_upload.append(leaf.local_data_source)
526526

527527
futures = []
528+
for local_source in needs_upload:
529+
future = self.loader.read_data_async(
530+
local_source, bigframes.core.guid.generate_guid()
531+
)
532+
533+
def cache_result(
534+
future: concurrent.futures.Future,
535+
local: local_data.ManagedArrowTable = local_source,
536+
):
537+
self.cache.cache_remote_replacement(local, future.result())
538+
539+
future.add_done_callback(cache_result)
540+
futures.append(future)
528541
try:
529-
for local_source in needs_upload:
530-
future = self.loader.read_data_async(
531-
local_source, bigframes.core.guid.generate_guid()
532-
)
533-
future.add_done_callback(
534-
lambda f: self.cache.cache_remote_replacement(
535-
local_source, f.result()
536-
)
537-
)
538-
futures.append(future)
539-
concurrent.futures.wait(futures)
540-
for future in futures:
542+
for future in concurrent.futures.as_completed(futures):
541543
future.result()
542544
except Exception as e:
543545
# cancel all futures

0 commit comments

Comments
 (0)