fix: retain native save completion through cancellation and restart

This commit is contained in:
阿白叔 committed 2026-11-24 08:48:33 +08:00
1 parent 18349413c5
commit 443668aa4b
11 files changed
+220 -45

No files matched your search

+3 -3
View File
@@ -66,10 +66,10 @@ def test_catalog_recovery_only_adopts_an_exact_exited_supervisor(tmp_path, monke
job = dict(record, supervisor_pid=55, session_record_path=str(path))
(tmp_path/'request.json').write_text(json.dumps(job), encoding='utf-8')
monkeypatch.setattr(residual_sessions, '_recorded_process_exited', lambda found: found == identity)
assert residual_sessions.orphaned_catalog_session(path)
assert residual_sessions.recoverable_orphan_session(path)
job['supervisor_identity'] = {**identity, 'pid': 56}
(tmp_path/'request.json').write_text(json.dumps(job), encoding='utf-8')
assert not residual_sessions.orphaned_catalog_session(path)
assert not residual_sessions.recoverable_orphan_session(path)
def test_idle_orphan_catalog_can_close_without_final_result(tmp_path, monkeypatch):
@@ -78,7 +78,7 @@ def test_idle_orphan_catalog_can_close_without_final_result(tmp_path, monkeypatc
root, job, _, _, state = owned_fixture(tmp_path, monkeypatch, 'catalog')
(root/'result.json').unlink()
monkeypatch.setattr(residual_sessions, 'orphaned_catalog_session', lambda _: True, raising=False)
monkeypatch.setattr(residual_sessions, 'recoverable_orphan_session', lambda _: True, raising=False)
session_record.write_session_record(root/'worker-state.json',
dict(operation_id='owned', phase='NATIVE_CALL', processes=[dict(role='native', pid=12,
created_handle='native-created', image='D:/Mentor/LibraryManager.exe', owner_sid='owner', session_id=1)]))