Skip to content

Commit a600db5

Browse files
committed
Fix: Enhance object addition verification in LiveBackend to prevent race conditions
1 parent 4894cbc commit a600db5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

datalab_kernel/workspace.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,19 @@ def add(self, name: str, obj: DataObject, overwrite: bool = False) -> None:
480480
# Wait for object to appear (cross-thread signal processing)
481481
# On slow CI, the first add can trigger lazy initialization that takes
482482
# 15+ seconds on Python 3.13. Use 60s timeout to be safe.
483+
#
484+
# We also verify the object is retrievable via get_object(), not just
485+
# that it appears in titles. This avoids race conditions where the title
486+
# appears but the object isn't fully ready for retrieval yet.
483487
for _ in range(600): # 60 seconds total timeout
484488
try:
485489
titles = self.proxy.get_object_titles(panel=panel)
486490
if name in titles:
487-
return # Object successfully added
491+
# Double-check object is actually retrievable
492+
# This catches race conditions where title appears before
493+
# the object is fully indexed
494+
self.proxy.get_object(name, panel=panel)
495+
return # Object successfully added and retrievable
488496
except Exception: # pylint: disable=broad-exception-caught
489497
pass
490498
time.sleep(0.1)

0 commit comments

Comments
 (0)