diff --git a/src/cbb_refresh_verify/icdb_ownership.py b/src/cbb_refresh_verify/icdb_ownership.py index 5d4068b..31d56e5 100644 --- a/src/cbb_refresh_verify/icdb_ownership.py +++ b/src/cbb_refresh_verify/icdb_ownership.py @@ -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) diff --git a/tests/test_issue21_batch_entry.py b/tests/test_issue21_batch_entry.py index 1e5eb82..49b5d8f 100644 --- a/tests/test_issue21_batch_entry.py +++ b/tests/test_issue21_batch_entry.py @@ -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()