fix: bound slow CAD startup and retain blocked COM diagnostics
This commit is contained in:
1 parent
29ea67c35e
commit
9b2372e389
2 files changed
+40
-1
No files matched your search
@@ -101,7 +101,7 @@ class IsolatedCadSession:
|
||||
probe = self.desktop.start_process(_helper_command('probe', bootstrap, self.cad.pid), env=_child_environment(environment),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
try:
|
||||
deadline = time.monotonic() + 75
|
||||
deadline = time.monotonic() + 120
|
||||
while probe.poll() is None:
|
||||
self._check_abort()
|
||||
if time.monotonic() >= deadline:
|
||||
@@ -189,6 +189,20 @@ def run_isolated_process(command, timeout, *, abort_event=None, cooperative_abor
|
||||
|
||||
def native_action(action, evidence, expected_pid):
|
||||
"""Runs in a child created with lpDesktop, never in a Python thread switch."""
|
||||
if action != 'probe':
|
||||
return _native_action(action, evidence, expected_pid)
|
||||
# COM startup can block inside a native call, so keep diagnostics outside
|
||||
# the redirected pipes and retain them when the supervisor ends the child.
|
||||
import faulthandler
|
||||
with Path(str(evidence) + '.fault.txt').open('a', encoding='utf-8') as trace:
|
||||
faulthandler.dump_traceback_later(20, repeat=True, file=trace)
|
||||
try:
|
||||
return _native_action(action, evidence, expected_pid)
|
||||
finally:
|
||||
faulthandler.cancel_dump_traceback_later()
|
||||
|
||||
|
||||
def _native_action(action, evidence, expected_pid):
|
||||
import pythoncom
|
||||
import win32com.client
|
||||
import win32gui
|
||||
|
||||
Reference in new issue
Block a user