fix: cancel superseded release probes without stopping the batch

This commit is contained in:
阿白叔 committed 2026-11-25 16:15:26 +08:00
1 parent b9d52e84cd
commit 0c02ff6966
2 files changed
+52 -10

No files matched your search

+22
View File
@@ -145,6 +145,7 @@ def test_natural_native_exit_gets_fresh_release_and_admits_waiting_scope_without
assert future.result(8)=='fresh admission'
thread.join(3)
assert not thread.is_alive() and closed==[0]
assert not stop.is_set(), 'retiring the observer must not cancel its caller'
observations=[json.loads(p.read_text()) for p in evidence.glob('observation-*.json')]
assert any(o.get('status')=='RELEASED' and o['release_proof']['proof_block_name']=='A' for o in observations)
assert original.read_bytes()==before
@@ -152,3 +153,24 @@ def test_natural_native_exit_gets_fresh_release_and_admits_waiting_scope_without
gate.touch();native.wait(5);stop.set()
if thread:thread.join(3)
cleanup(lease)
def test_stopped_observer_does_not_start_a_second_library_probe(tmp_path, monkeypatch):
from test_session_record import record
import subprocess
import sys
with subprocess.Popen([sys.executable, '-c', 'import time; time.sleep(30)']) as native:
identity = session_record.process_identity(native.pid)
native.terminate()
native.wait(5)
path = record(tmp_path, [dict(role='native', **identity)])
stop = Event()
stop.set()
probes = []
monkeypatch.setattr('cbb_refresh_verify.library_lock.release_retained_library',
lambda *args, **kwargs: probes.append(args))
session_record.observe_retained_session(path, evidence_root=tmp_path, stop=stop)
assert probes == []