fix: preserve a queued retry while an identified Mentor save runs

This commit is contained in:
阿白叔 committed 2026-11-25 10:10:21 +08:00
1 parent 6aed02d26b
commit 2722d09b59
3 files changed
+32 -3

No files matched your search

+5 -1
View File
@@ -322,6 +322,7 @@ def _reconcile(path, root, handles, stack, *, release=True, stop=None):
from .residual_sessions import _handle_identity, _force_ownership
session, state, processes = _session(path, root)
active = False
active_helper = False
for identity in processes:
if identity.get('role') == 'supervisor':
continue
@@ -352,8 +353,11 @@ def _reconcile(path, root, handles, stack, *, release=True, stop=None):
handle = handles[key]
if handle is not None and win32event.WaitForSingleObject(handle, 0) != win32con.WAIT_OBJECT_0:
active = True
active_helper |= identity.get('role') == 'helper'
if active:
return _result('ACTIVE', '原生调用尚未确认返回', session=session, state=state)
saving = active_helper and session.get('operation') == 'verify' and state.get('phase') == 'NATIVE_CALL'
detail = 'Mentor 正在保存,结束后自动复核释放。' if saving else '原生调用尚未确认返回'
return {**_result('ACTIVE', detail, session=session, state=state), 'active_save': saving}
if not release:
return {**_result('UNCONFIRMED', '记录中的进程已退出,需确认库占用已释放',
session=session, state=state), 'processes_exited': True}
+8 -2
View File
@@ -1598,7 +1598,8 @@ def wait_for_batch_release(request, context, *, progress=None, timeout_seconds=1
library = request.lmc_file
if not Path(library).is_file():
return
deadline = time.monotonic() + timeout_seconds
started = time.monotonic()
deadline = started + timeout_seconds
previous = None
while True:
context.check_active()
@@ -1612,7 +1613,12 @@ def wait_for_batch_release(request, context, *, progress=None, timeout_seconds=1
context.check_active()
return
else:
detail = library_wait_reason(library)
sessions = retained_session_states(library)
if any(value.get('active_save') is True for value in sessions):
deadline = max(deadline, started + request.timeout_seconds)
detail = 'Mentor 正在保存,结束后自动复核释放。'
else:
detail = library_wait_reason(library)
if detail != previous:
_notify_progress(progress, {'stage': 'waiting_native_slot', 'library': str(library),
'retained': True, 'detail': detail})