fix: close a proven design after interrupted PCB startup
This commit is contained in:
1 parent
9fa9625dba
commit
b3d69ee722
2 files changed
+40
-12
No files matched your search
@@ -1125,14 +1125,31 @@ def finish_owned_idle_session(path, *, stop=None):
|
||||
and owner.get('force_user_confirmed') is True
|
||||
and _handle_identity(handle) == {k:client[k] for k in ('created_handle','image')}
|
||||
and all(owner.get(k) == client[k] for k in ('owner_sid','session_id')))
|
||||
def empty_target():
|
||||
def idle_target():
|
||||
snapshot = _process_windows({client['pid']}, include_hidden_documents=True)
|
||||
windows = snapshot.get(client['pid'], [])
|
||||
if (any(w.get('desktop') != desktop or w.get('documents')
|
||||
or any(c['class'].casefold().startswith('afx:') and c.get('visible') is False
|
||||
for c in w.get('children',[])) for w in windows)):
|
||||
if any(w.get('desktop') != desktop or any(
|
||||
c['class'].casefold().startswith('afx:') and c.get('visible') is False
|
||||
for c in w.get('children', [])) for w in windows):
|
||||
return None
|
||||
return close_target(client_name, windows, incomplete=_window_error(snapshot,client['pid']))[0]
|
||||
target, _ = close_target(client_name, windows, incomplete=_window_error(snapshot, client['pid']))
|
||||
if target is None or not any(w.get('documents') for w in windows):
|
||||
return target
|
||||
if orphan_client is None:
|
||||
return None
|
||||
# PCB can finish loading after its worker has stopped. Close
|
||||
# only the design independently bound by this launch's logs.
|
||||
from .diagnostic_open import _load_evidence, _target_frame
|
||||
from .failed_session import cancelled_prewrite_startup
|
||||
baseline = cancelled_prewrite_startup(job, client['pid'])
|
||||
if baseline is None:
|
||||
return None
|
||||
frames = _legacy_diagnostic_windows(dict(client, cleanup_desktop=desktop))
|
||||
frame = _target_frame(frames, Path(job['pcb']).stem)
|
||||
if (frame and frame['hwnd'] == target['hwnd']
|
||||
and _load_evidence(job, client['pid'], baseline, require_autosave=False) is not None):
|
||||
return target
|
||||
return None
|
||||
def startup_prompt():
|
||||
from .failed_session import _startup_snapshot, _cancel_target, _tip_target
|
||||
snapshot = _process_windows({client['pid']}, include_hidden_documents=True)
|
||||
@@ -1165,7 +1182,7 @@ def finish_owned_idle_session(path, *, stop=None):
|
||||
if (cancelled_before_write is not None
|
||||
and cancelled_prewrite_startup(job, client['pid']) != cancelled_before_write):
|
||||
return False
|
||||
target = empty_target()
|
||||
target = idle_target()
|
||||
prompt = startup_prompt() if target is None and (cancelled_before_write is not None or orphan_client is not None) else None
|
||||
if (target is None and prompt is None) or stop is not None and stop.is_set(): return False
|
||||
check_active()
|
||||
@@ -1181,7 +1198,7 @@ def finish_owned_idle_session(path, *, stop=None):
|
||||
or latest.get('owned_idle_cleanup') != claim
|
||||
or any(latest.get(k) != v for k,v in session.items() if k != 'recorded_at')
|
||||
or not same_client() or read('request.json') != job
|
||||
or (empty_target() != target if prompt is None else startup_prompt() != prompt)
|
||||
or (idle_target() != target if prompt is None else startup_prompt() != prompt)
|
||||
or (cancelled_before_write is not None
|
||||
and cancelled_prewrite_startup(job, client['pid']) != cancelled_before_write)
|
||||
or read_result() != result or result is None and not recoverable_orphan_session(path)
|
||||
@@ -1204,11 +1221,11 @@ def finish_owned_idle_session(path, *, stop=None):
|
||||
while time.monotonic() < deadline and same_client():
|
||||
if stop is not None and stop.is_set():
|
||||
break
|
||||
target = empty_target()
|
||||
target = idle_target()
|
||||
if target is not None:
|
||||
break
|
||||
time.sleep(.1)
|
||||
if (target is not None and (not same_client() or empty_target() != target
|
||||
if (target is not None and (not same_client() or idle_target() != target
|
||||
or orphan_client is not None and not recoverable_orphan_session(path)
|
||||
or cancelled_before_write is not None
|
||||
and cancelled_prewrite_startup(job, client['pid']) != cancelled_before_write)):
|
||||
|
||||
Reference in new issue
Block a user