fix: wait for native iCDB shutdown after a completed save
This commit is contained in:
1 parent
81a5d1ae4b
commit
dfb819e7dd
4 files changed
+69
-10
No files matched your search
@@ -3,6 +3,10 @@ from pathlib import Path
|
||||
import time
|
||||
|
||||
|
||||
# EE 7.9.5 has taken over three minutes to close a saved Work database.
|
||||
SAVED_DATABASE_RELEASE_TIMEOUT_SECONDS = 240
|
||||
|
||||
|
||||
def session_resource_scope(job):
|
||||
"""Persist declared targets; only fresh proof promotes them to observed scope."""
|
||||
library = Path(job['library'])
|
||||
@@ -35,13 +39,14 @@ def unreleased_addresses(lmc_file, project, pcb):
|
||||
|
||||
|
||||
def wait_for_saved_database_release(library, project, pcb, *, stop=None,
|
||||
report_pending=lambda **event: None, timeout_seconds=75):
|
||||
report_pending=lambda **event: None,
|
||||
timeout_seconds=SAVED_DATABASE_RELEASE_TIMEOUT_SECONDS):
|
||||
"""Check scoped files after PCB exits, outside the host native channel."""
|
||||
from .file_probe import hold_release_files
|
||||
from .operation_queue import native_phase, note_metadata_progress
|
||||
|
||||
deadline = time.monotonic() + timeout_seconds
|
||||
reported = None
|
||||
last_lock = None
|
||||
while True:
|
||||
try:
|
||||
# The file helper has its own bounded deadline. Preserve its result
|
||||
@@ -53,16 +58,23 @@ def wait_for_saved_database_release(library, project, pcb, *, stop=None,
|
||||
winerror = getattr(error, 'winerror', None)
|
||||
blocked = getattr(error, 'blocked_resources', [])
|
||||
remaining = deadline - time.monotonic()
|
||||
if winerror not in (32, 33) or remaining <= 0:
|
||||
return {'status': 'IN_USE' if winerror in (32, 33) else 'UNCONFIRMED',
|
||||
'detail': str(error), 'winerror': winerror, 'blocked_resources': blocked}
|
||||
if stop is not None and stop.is_set():
|
||||
return {'status': 'UNCONFIRMED', 'detail': '已取消释放检查',
|
||||
'blocked_resources': last_lock['blocked_resources'] if last_lock else blocked}
|
||||
if winerror in (32, 33):
|
||||
if remaining > 0 and (last_lock is None or blocked != last_lock['blocked_resources']):
|
||||
report_pending(blocked_resources=blocked)
|
||||
last_lock = {'status': 'IN_USE', 'detail': str(error), 'winerror': winerror,
|
||||
'blocked_resources': blocked}
|
||||
elif not isinstance(error, TimeoutError) or last_lock is None:
|
||||
return {'status': 'UNCONFIRMED', 'detail': str(error), 'winerror': winerror,
|
||||
'blocked_resources': blocked}
|
||||
if remaining <= 0:
|
||||
detail = last_lock['detail']
|
||||
if isinstance(error, TimeoutError):
|
||||
detail = f'最后确认的占用:{detail}。最后一次探测:{error}'
|
||||
return {**last_lock, 'detail': detail}
|
||||
note_metadata_progress()
|
||||
if blocked != reported:
|
||||
report_pending(blocked_resources=blocked)
|
||||
reported = blocked
|
||||
time.sleep(min(1, remaining))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user