fix: continue released verify batches and bound automation shutdown

This commit is contained in:
阿白叔 committed 2026-11-04 20:51:35 +08:00
1 parent 477a5a46e3
commit 00db1cf5f2
23 files changed
+550 -115

No files matched your search

+5 -2
View File
@@ -211,7 +211,8 @@ class BatchStatusSession:
queried = 0
for index, name in enumerate(names):
previous = checkpoint.get(name)
if previous and previous.fingerprint == fingerprint.sha256:
if (previous and previous.status in {'READY', 'PENDING'}
and previous.fingerprint == fingerprint.sha256):
results.append(previous)
continue
try:
@@ -231,7 +232,9 @@ class BatchStatusSession:
except BridgeResponseError as error:
message = str(error)
lower_message = message.casefold()
unavailable = any(marker in message for marker in ("LMCDLL70", "私有 MFC", "未找到可用"))
unavailable = any(marker in message for marker in ("LMCDLL70", "私有 MFC", "未找到可用")) or any(
code in lower_message for code in ('0xc0000135', '-1073741515', '3221225781',
'0xc000007b', '-1073741701', '3221225595'))
malformed = (any(marker in message for marker in (
"路径不匹配", "请求标识不匹配", "CBB 标识不匹配",
)) or "mismatch" in lower_message)
+40 -8
View File
@@ -22,7 +22,7 @@ def launch_save_helper(command, **kwargs):
return helper
def start_supervisor_watchdog(supervisor_pid, *, cancel_path=None):
def start_supervisor_watchdog(supervisor_pid, *, cancel_path=None, stop_clients=False):
"""A crashed supervisor must not leave unsupervised automation writing.
Stop only this Python worker and its registered automation clients. Native
@@ -38,7 +38,9 @@ def start_supervisor_watchdog(supervisor_pid, *, cancel_path=None):
# Let native calls finish before the worker closes its exact
# document. Killing a pending automation client can abandon it.
Path(cancel_path).touch()
return
if not stop_clients:
return
threading.Event().wait(5)
with _automation_clients_lock:
for helper in _automation_clients:
try:
@@ -48,7 +50,7 @@ def start_supervisor_watchdog(supervisor_pid, *, cancel_path=None):
pass
finally:
parent.Close()
if cancel_path is None:
if cancel_path is None or stop_clients:
os._exit(75)
thread = threading.Thread(target=watch, name='supervisor-watchdog', daemon=True)
@@ -118,9 +120,38 @@ class DesktopWorker:
return int(pid)
def poll(self):
if getattr(self, '_closed', False):
return self._exit_code
code = win32process.GetExitCodeProcess(self.handle)
return None if code == 259 else code
def _save_clients(self):
from .owner_probe import query_owners
from .failed_session import _command_args
expected = {Path(__file__).with_name(name).resolve()
for name in ('save_verified_block.vbs', 'close_failed_block.vbs')}
clients = []
for row in query_owners(('cscript.exe',), timeout_seconds=3):
if row.get('parent') != self.pid:
continue
args = _command_args(row['command'])
if any(Path(arg).resolve() in expected for arg in args[1:] if arg.casefold().endswith('.vbs')):
clients.append(row['pid'])
return clients
def automation_release_state(self):
try:
remaining = self._save_clients()
return {'safe_to_continue': self.poll() is not None and not remaining,
'remaining_pids': remaining}
except Exception as error:
return {'safe_to_continue': False, 'remaining_pids': [], 'error': str(error)}
def stop_automation_clients(self):
from .mentor_adapter import _terminate_pid
for pid in self._save_clients():
_terminate_pid(pid)
@property
def returncode(self):
return self.poll()
@@ -132,12 +163,9 @@ class DesktopWorker:
except Exception:
pass
# The worker is now stopped and cannot spawn another save helper.
from .mentor_adapter import _process_details, _terminate_pid
try:
for pid, _exe, command, parent in _process_details('cscript.exe'):
if (int(parent or 0) == self.pid
and 'save_verified_block.vbs' in str(command).casefold()):
_terminate_pid(pid) # single automation process, no /T
self.wait(timeout=5)
self.stop_automation_clients()
except Exception:
pass
for companion in self.companions:
@@ -162,6 +190,8 @@ class DesktopWorker:
return self.poll()
def close(self):
if getattr(self, '_closed', False):
return
# Releasing Python resources must not kill native database owners.
try:
if self.poll() is None:
@@ -177,7 +207,9 @@ class DesktopWorker:
pass
self.companions.clear()
self.companion_pids.clear()
self._exit_code = self.poll()
self.handle.Close()
self._closed = True
# Native processes keep their desktop alive if manual recovery is needed.
self.job.Close()
if self.desktop is not None:
+25 -22
View File
@@ -217,23 +217,12 @@ def launch_pcb_process(command, cwd):
def _process_details(name):
queries = {
'ExpeditionPCB.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='ExpeditionPCB.exe'",
'LibraryManager.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='LibraryManager.exe'",
'iCDBProjectBackup.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='iCDBProjectBackup.exe'",
'ReuseBlockImporter.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='ReuseBlockImporter.exe'",
'cscript.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='cscript.exe'",
'viewdraw.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='viewdraw.exe'",
}
if name not in queries:
if name not in {'ExpeditionPCB.exe', 'LibraryManager.exe', 'iCDBProjectBackup.exe',
'ReuseBlockImporter.exe', 'cscript.exe', 'viewdraw.exe'}:
raise ValueError(f'Unsupported process query: {name}')
import win32com.client
service = win32com.client.GetObject('winmgmts:')
return [
(int(p.ProcessId), str(p.ExecutablePath or ''), str(p.CommandLine or ''),
int(p.ParentProcessId or 0))
for p in service.ExecQuery(queries[name])
]
from .owner_probe import query_owners
return [(row['pid'], row['executable'], row['command'], row['parent'])
for row in query_owners((name,))]
def _processes(name):
@@ -616,11 +605,15 @@ def execute_job(job, emit):
root = Path(job['root'])
block_root = Path(job['project']).parent.parent
# COM publishes a shared active application. Never attach while another
# native PCB session (including a retained failure) is still running.
pcb_before = {pid for pid, _, _ in pcb_processes()}
if pcb_before:
raise RuntimeError(f'PCB_SESSION_ACTIVE: 已有 PCB 会话,请正常关闭后再校验: {sorted(pcb_before)}')
# Unrelated designs stay open; COM and save helpers still require the exact
# project identity before any integration or save call.
from .failed_session import _command_args
existing = tuple(pcb_processes())
pcb_before = {pid for pid, _, _ in existing}
expected = os.path.normcase(os.path.abspath(job['pcb']))
for pid, _, command in existing:
if command and expected in [os.path.normcase(os.path.abspath(a)) for a in _command_args(command)[1:]]:
raise RuntimeError(f'PCB_SESSION_ACTIVE: 目标工程已经打开:{pid}')
# Backups are user-managed on local and network libraries alike.
mapped_drive = str(job.get('mapped_drive') or '')
mapped_remote_root = str(job.get('mapped_remote_root') or '')
@@ -820,6 +813,8 @@ def execute_job(job, emit):
emit(stage='save_helper', helper_pid=helper.pid)
last_markers = ()
while helper.poll() is None:
if job.get('cancel_signal') and Path(job['cancel_signal']).exists():
raise RuntimeError('VERIFY_CANCELLED: 已停止等待保存客户端')
try:
current = tuple(line.strip() for line in (root/'save.log').read_text(encoding='utf-8', errors='replace').splitlines() if line.strip())
except OSError:
@@ -939,6 +934,14 @@ def cleanup_verify_processes(lm_pid, worker_pid, worker_parent_pid=None, *,
if (expected_pcb and int(pid) not in baseline
and is_reusable_circuit_pcb(executable, command, expected_pcb)):
tracked.add(int(pid))
# Native launcher children can omit the PCB argument. Track only new
# descendants of this task's already identified native processes.
while True:
children = {int(pid) for pid, _, _, parent in pcb_records
if int(pid) not in baseline and int(parent) in tracked}
if children.issubset(tracked):
break
tracked.update(children)
alive = {int(record[0]) for record in (*pcb_records, *lm_records)}
remaining = sorted(tracked & alive)
result = {'safe_to_continue': not remaining, 'remaining_pids': remaining}
@@ -984,7 +987,7 @@ def worker_main(request_path):
try:
if job.get('supervisor_pid'):
from .desktop_worker import start_supervisor_watchdog
start_supervisor_watchdog(job['supervisor_pid'], cancel_path=job.get('cancel_signal'))
start_supervisor_watchdog(job['supervisor_pid'], cancel_path=job.get('cancel_signal'), stop_clients=True)
start_gate = Path(job.get('start_gate', '')) if job.get('start_gate') else None
if start_gate is not None:
gate_deadline = time.monotonic() + 15
+5 -3
View File
@@ -31,7 +31,8 @@ def query_owners(names, *, timeout_seconds=10):
raise ValueError('invalid result')
for row in rows:
if (type(row['pid']) is not int or row['pid'] <= 0 or row['name'].casefold() not in {n.casefold() for n in names}
or not isinstance(row['command'], str)):
or not isinstance(row['command'], str) or not isinstance(row['executable'], str)
or type(row['parent']) is not int or row['parent'] < 0):
raise ValueError('invalid owner')
return rows
except (OSError, ValueError, KeyError, TypeError, AttributeError) as error:
@@ -48,10 +49,11 @@ def owner_probe_main(job):
pythoncom.CoInitialize()
try:
service = win32com.client.GetObject('winmgmts:')
query = 'SELECT ProcessId,Name,CommandLine FROM Win32_Process WHERE ' + ' OR '.join(
query = 'SELECT ProcessId,Name,CommandLine,ExecutablePath,ParentProcessId FROM Win32_Process WHERE ' + ' OR '.join(
f"Name='{name}'" for name in names)
rows = [{'pid': int(item.ProcessId), 'name': str(item.Name),
'command': str(item.CommandLine or '')} for item in service.ExecQuery(query)]
'command': str(item.CommandLine or ''), 'executable': str(item.ExecutablePath or ''),
'parent': int(item.ParentProcessId or 0)} for item in service.ExecQuery(query)]
service = None
job.with_name('result.json').write_text(json.dumps({'names': names, 'owners': rows}), encoding='utf-8')
return 0
@@ -1,5 +1,5 @@
Option Explicit
Dim app, doc, pi, licensing, token, expected, attempt, stable, measuredStart, operationOK
Dim app, doc, pi, licensing, token, expected, attempt, stable, measuredStart, operationOK, remaining
expected = WScript.Arguments(0)
Set app = GetObject(, "MGCPCB.Application")
Set doc = app.ActiveDocument
@@ -55,6 +55,13 @@ WScript.Echo "CLOSE_OK"
Set pi = Nothing
Set doc = Nothing
Set licensing = Nothing
Set remaining = app.ActiveDocument
If Not remaining Is Nothing Then
Set remaining = Nothing
WScript.Echo "APP_RETAINED_OTHER_DOCUMENT"
WScript.Quit 10
End If
Set remaining = Nothing
measuredStart = Timer
app.Quit
LogElapsed "quit", measuredStart
+2 -2
View File
@@ -315,7 +315,7 @@ class MainWindow(QWidget):
self.counts_label.setText(f'可见 {counts["visible"]} / {len(self._records_by_name)} · '
f'READY {counts["ready"]} · 异常/待确认 {counts["error"]}')
self.stop_button.setEnabled(self.busy and self.loaded_path is not None and not self.stop.is_set())
self.stop_button.setText('取消当前检查并停止队列' if self._global_icdb_run else '当前项完成后停止')
self.stop_button.setText('取消当前任务并停止队列')
available = bool(self._reimport_offers) and not self.busy and self.management_capabilities['update'].supported
self.reimport_button.setVisible(bool(self._reimport_offers))
self.reimport_button.setEnabled(available)
@@ -888,7 +888,7 @@ class MainWindow(QWidget):
'native_repair_finished': '原生修复已结束,正在核对结果'}
if stage in phases:
self.icdb_phase.setText(f'{block or ""} · {phases[stage]}')
if block and stage in {'PASS', 'FAIL', 'BLOCKED', 'TIMEOUT', 'SKIPPED', 'CHECKED', 'REPAIRED'}:
if block and stage in {'PASS', 'FAIL', 'BLOCKED', 'TIMEOUT', 'SKIPPED', 'CHECKED', 'REPAIRED', 'CANCELLED'}:
row = self._row_by_name.get(block)
if row is not None:
detail = str(event.get('detail') or event.get('error') or '').strip()
+77 -28
View File
@@ -56,7 +56,7 @@ class VerifyRequest:
# A reserved iCDB range is a host-wide prerequisite failure. Do not
# launch a PCB that is guaranteed to time out; batch orchestration will
# record this item and continue with the next one.
strict_port_check: bool = True
strict_port_check: bool = False
# A mapped drive can be invisible to an elevated/private worker on Win10.
# Preserve the parent session's mapping identity so the worker can restore
# it before launching Library Manager/PCB.
@@ -135,7 +135,8 @@ def classify_output(exit_code: int | None, output: str, *, timed_out: bool = Fal
from .icdb_recovery import parse_session_loss
if parse_session_loss(output):
return 'FAIL'
if exit_code == 0 and SUCCESS_TEXT.search(output) and not ERROR_TEXT.search(output):
diagnostic_text = re.sub(r'\b0\s+errors?\b', '', output, flags=re.I)
if exit_code == 0 and SUCCESS_TEXT.search(output) and not ERROR_TEXT.search(diagnostic_text):
return 'PASS'
if ERROR_TEXT.search(output):
return 'FAIL'
@@ -157,7 +158,8 @@ def preflight(request):
if len(projects) != 1:
raise ValueError(f'{name}: 缺少或无法唯一确定 Work 下的工程 PRJ')
project = absolute_preserving_drive(projects[0])
content = project.read_text(encoding='utf-8', errors='replace')
from .backup_recovery import _project_text
content = _project_text(project)
refs = re.findall(r'^KEY PCBDesignPath "([^"]+)"', content, re.M)
if not refs:
raise ValueError(f'{name}: 工程没有 PCBDesignPath')
@@ -220,7 +222,17 @@ def _stop_worker(process, *, timeout=5):
try:
process.wait(timeout=timeout)
except Exception:
pass
try:
process.kill() # Automation clients only; never the native tree.
process.wait(timeout=5)
except Exception:
pass
try:
if hasattr(process, 'stop_automation_clients'):
process.stop_automation_clients()
return process.poll() is not None
except Exception:
return False
def _normalize_bridge_result(probe):
@@ -480,7 +492,7 @@ def native_lm_verify_enabled():
}
def _cleanup_session_processes(root, *, lm_pid, target_pid, pcb, pcb_baseline,
def _cleanup_session_processes(root, *, lm_pid, target_pid, pcb, pcb_baseline, launcher_pid=None,
progress=None):
"""Record native release or retention after automation has stopped."""
from .mentor_adapter import cleanup_verify_processes
@@ -504,7 +516,7 @@ def _cleanup_session_processes(root, *, lm_pid, target_pid, pcb, pcb_baseline,
return cleanup_verify_processes(
lm_pid,
target_pid,
None,
launcher_pid,
expected_pcb=pcb,
baseline_pids=pcb_baseline,
emit=emit,
@@ -554,7 +566,7 @@ def run_verify(request, *, progress=None, flag_reader=None, process_runner=None,
result = _run_verify_serialized(
request, progress=progress, flag_reader=flag_reader,
process_runner=process_runner, port_check=port_check,
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt)
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt, stop=stop)
if (request.auto_repair and result.status not in {'TIMEOUT', 'BLOCKED'}
and result.error_category == 'ICDB_REPAIR_REQUIRED'
and result.evidence_path):
@@ -639,7 +651,9 @@ def run_verify(request, *, progress=None, flag_reader=None, process_runner=None,
release_confirmed = (release.get('worker_exited') is True
and release.get('safe_to_continue') is True and release.get('block') == request.block_name
and Path(release['library']).resolve() == Path(request.lmc_file).resolve())
if (release.get('worker_exited') is True and release.get('block') == request.block_name
if (release.get('worker_exited') is True and not release.get('error')
and not release.get('close_errors') and not release.get('automation_release', {}).get('error')
and release.get('block') == request.block_name
and Path(release['library']).resolve() == Path(request.lmc_file).resolve()):
remaining_clients = tuple(pid for pid in release.get('remaining_pids', [])
if type(pid) is int and pid > 0)
@@ -658,12 +672,23 @@ def run_verify(request, *, progress=None, flag_reader=None, process_runner=None,
def _run_verify_serialized(request, *, progress=None, flag_reader=None, process_runner=None,
port_check=None, dialog_supervisor_factory=None, version_prompt=None):
port_check=None, dialog_supervisor_factory=None, version_prompt=None, stop=None):
timing = RunTimings()
result = _run_verify(request, timing=timing, progress=progress, flag_reader=flag_reader,
process_runner=process_runner, port_check=port_check,
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt)
if result.status not in {'PASS', 'SKIPPED', 'QUEUE_STOP'} and result.evidence_path:
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt, stop=stop)
if not request.auto_repair and result.evidence_path:
try:
release = json.loads(result.evidence_path.with_name('session-release.json').read_text('utf-8'))
if (release.get('block') == request.block_name
and Path(release['library']).resolve() == Path(request.lmc_file).resolve()):
released = release.get('worker_exited') is True and release.get('safe_to_continue') is True
result = replace(result, safe_to_continue=released)
if not released and result.status == 'PASS':
result = replace(result, status='FAIL', stderr='原生会话或自动化客户端尚未退出。')
except (OSError, ValueError, KeyError):
pass
if result.status not in {'PASS', 'SKIPPED', 'QUEUE_STOP', 'CANCELLED'} and result.evidence_path:
job_path = result.evidence_path.with_name('request.json')
if job_path.is_file():
timing.begin('failure_diagnostics')
@@ -690,16 +715,6 @@ def _run_verify_serialized(request, *, progress=None, flag_reader=None, process_
if recovery and RECOVERY_ACTION not in detail:
detail = (detail + '\n' + recovery_detail(recovery)).strip()
result = replace(result, stderr=detail, error_category=ERROR_CODE)
if not request.auto_repair and result.evidence_path:
try:
release = json.loads(result.evidence_path.with_name('session-release.json').read_text('utf-8'))
if (result.error_stage in {'PCB_STARTING', 'pcb_startup'}
and release.get('worker_exited') is True and release.get('safe_to_continue') is True
and release.get('block') == request.block_name
and Path(release['library']).resolve() == Path(request.lmc_file).resolve()):
result = replace(result, safe_to_continue=True)
except (OSError, ValueError, KeyError):
pass
if recovery and result.evidence_path:
try:
record_path = result.evidence_path.parent/'diagnostics/icdb-recovery.json'
@@ -737,7 +752,7 @@ def _run_verify_serialized(request, *, progress=None, flag_reader=None, process_
def _run_verify(request, *, timing, progress=None, flag_reader=None, process_runner=None, port_check=None,
dialog_supervisor_factory=None, version_prompt=None):
dialog_supervisor_factory=None, version_prompt=None, stop=None):
"""Refresh one CBB and record its evidence.
``flag_reader`` is a read-only probe returning an authoritative ``BridgeResult``.
@@ -769,6 +784,8 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
pass
return replace(result, evidence_path=result_path)
if stop is not None and stop.is_set():
return finish(VerifyResult('CANCELLED', stderr='已取消,未启动校验。'))
timing.begin('preflight')
try:
project, pcb = preflight(request)
@@ -809,8 +826,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
if progress:
progress({'stage': 'content_check_done', 'block': request.block_name, 'status': 'PASS'})
# The design server needs a port in 10000-10100; a system reservation there
# blocks every item, so fail fast with the fix instead of timing out.
# Sampling cannot establish that the whole native port range is unusable.
from .mentor_adapter import icdb_ports_bindable
check_ports = port_check or icdb_ports_bindable
ports_ok, ports_detail = check_ports()
@@ -898,6 +914,10 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
)
Path(job['start_gate']).touch()
while process.poll() is None:
if stop is not None and stop.is_set():
_stop_worker(process)
return finish(VerifyResult('CANCELLED', stderr='已取消当前校验。',
safe_to_continue=False, error_stage=phase.value))
if events.exists():
with events.open(encoding='utf-8') as stream:
stream.seek(offset)
@@ -1043,7 +1063,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
'observation': last_post_verify_observation,
})
return finish(VerifyResult(status, stderr=detail, safe_to_continue=False))
return finish(VerifyResult('TIMEOUT', stderr='操作超时;已停止自动化并保留原生会话,停止批次,请检查恢复记录。', error_stage=phase.value, safe_to_continue=False))
return finish(VerifyResult('TIMEOUT', stderr='操作超时,当前项未完成。', error_stage=phase.value, safe_to_continue=False))
time.sleep(.2)
worker_result = root/'outcome.json'
if not worker_result.exists():
@@ -1058,6 +1078,8 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
return finish(VerifyResult('FAIL', stderr=str(error), safe_to_continue=False))
finally:
close_errors = []
worker_exited = False
automation_release = {'safe_to_continue': False}
if 'dialog_agent' in locals() and dialog_agent is not None:
try:
dialog_agent.close()
@@ -1065,15 +1087,37 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
close_errors.append(str(error))
if 'process' in locals():
try:
worker_exited = process.poll() is not None
if not worker_exited:
worker_exited = _stop_worker(process)
if hasattr(process, 'automation_release_state'):
automation_release = process.automation_release_state()
else:
automation_release = {'safe_to_continue': worker_exited, 'remaining_pids': []}
process.close()
except Exception as error:
close_errors.append(str(error))
if 'process' in locals():
try:
if events.is_file():
with events.open(encoding='utf-8') as stream:
stream.seek(offset)
for line in stream:
try:
event = json.loads(line)
timing.record(event)
if event.get('pcb_pid'): target_pid = event['pcb_pid']
if event.get('launcher_pid'): launcher_pid = event['launcher_pid']
if event.get('lm_pid'): lm_pid = event['lm_pid']
if event.get('stage') == 'pcb_baseline': pcb_baseline = set(event.get('pids', ()))
except (json.JSONDecodeError, ValueError):
continue
offset = stream.tell()
release_result = _cleanup_session_processes(
root,
lm_pid=lm_pid,
target_pid=target_pid,
launcher_pid=launcher_pid,
pcb=pcb,
pcb_baseline=pcb_baseline,
progress=progress,
@@ -1090,17 +1134,22 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
if close_errors:
release_result = {**(release_result or {}), 'safe_to_continue': False,
'close_errors': close_errors}
if not worker_exited or not automation_release.get('safe_to_continue'):
release_result = {**(release_result or {}), 'safe_to_continue': False,
'automation_release': automation_release, 'worker_exited': worker_exited}
release_result['remaining_pids'] = sorted(set(release_result.get('remaining_pids', []))
| set(automation_release.get('remaining_pids', [])))
try:
(root/'session-release.json').write_text(json.dumps({
**(release_result or {}), 'block': request.block_name,
'library': str(request.lmc_file), 'worker_exited': process.poll() is not None,
'library': str(request.lmc_file), 'worker_exited': worker_exited,
'worker_pid': getattr(process, 'pid', None)},
ensure_ascii=False, default=str, indent=2), encoding='utf-8')
except OSError:
pass
if not release_result or not release_result.get('safe_to_continue'):
if 'result' in locals():
result = replace(result, status='FAIL', safe_to_continue=False,
result = replace(result, status='FAIL' if result.status == 'PASS' else result.status, safe_to_continue=False,
stderr=(result.stderr + '\nPCB_RELEASE_UNCONFIRMED: 未确认原生会话退出').strip())
recovery = {'desktop': job['desktop'], 'project': str(project),
'pcb': str(pcb), 'release': release_result,
@@ -1169,7 +1218,7 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
result = VerifyResult('FAIL', stderr=str(error), safe_to_continue=False)
results.append(result)
# Never start another writer after an unconfirmed native shutdown.
queue_stop = queue_stop or result.status == 'QUEUE_STOP' or not result.safe_to_continue
queue_stop = queue_stop or result.status in {'QUEUE_STOP', 'CANCELLED'} or not result.safe_to_continue
if queue_stop and stop is not None:
stop.set()
if progress: progress(request.block_name, result)