fix: keep the post-save release result through slow file probes

This commit is contained in:
阿白叔 committed 2026-11-25 11:19:34 +08:00
1 parent 2e87627ef1
commit edd1e088af
2 files changed
+36 -3

No files matched your search

+5 -3
View File
@@ -38,14 +38,16 @@ def wait_for_saved_database_release(library, project, pcb, *, stop=None,
report_pending=lambda **event: None, timeout_seconds=75):
"""Check scoped files after PCB exits, outside the host native channel."""
from .file_probe import hold_release_files
from .operation_queue import note_metadata_progress
from .operation_queue import native_phase, note_metadata_progress
deadline = time.monotonic() + timeout_seconds
reported = None
while True:
try:
with hold_release_files(library, saved_project=(project, pcb), timeout_seconds=deadline-time.monotonic(),
stop=stop) as proof:
# The file helper has its own bounded deadline. Preserve its result
# if a single SMB probe reaches the generic metadata timeout.
with native_phase(read_only=True), hold_release_files(
library, saved_project=(project, pcb), timeout_seconds=deadline-time.monotonic(), stop=stop) as proof:
return {**proof, 'status': 'RELEASE_CONFIRMED', 'blocked_resources': []}
except (OSError, ValueError) as error:
winerror = getattr(error, 'winerror', None)
+31
View File
@@ -46,3 +46,34 @@ def test_batch_waits_for_recorded_save_past_ordinary_release_deadline(tmp_path,
monkeypatch.setattr(context.stop, 'wait', lambda interval: waiting.append(interval))
verify_runner.wait_for_batch_release(request, context, timeout_seconds=0)
assert len(waiting) == 1
def test_completed_save_keeps_bounded_release_probe_alive(tmp_path, monkeypatch):
from contextlib import contextmanager
from threading import Event
from cbb_refresh_verify.icdb_ownership import wait_for_saved_database_release
entered, finish = Event(), Event()
@contextmanager
def probe(*args, **kwargs):
entered.set()
assert finish.wait(1)
yield {'exclusive_files': [str(tmp_path/'icdb.dat')]}
monkeypatch.setattr('cbb_refresh_verify.file_probe.hold_release_files', probe)
context = BatchTaskContext(str(tmp_path/'library.lmc'))
from threading import Thread
def finish_probe():
assert entered.wait(1)
Event().wait(.15)
finish.set()
thread = Thread(target=finish_probe)
thread.start()
try:
result = context.run(lambda: wait_for_saved_database_release(context.library,
tmp_path/'project.prj', tmp_path/'project.pcb'), timeout_seconds=.05)
assert result['status'] == 'RELEASE_CONFIRMED'
finally:
finish.set()
thread.join()