mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Fixed analysis not working on windows
This commit is contained in:
1 parent
cd1914216f
commit
ebe30c1128
1 file changed
+22
@@ -28,7 +28,16 @@ def _watch_parent_and_exit() -> None:
|
|||||||
shut down, so the backend can never be orphaned (the Rust-side kill-on-exit
|
shut down, so the backend can never be orphaned (the Rust-side kill-on-exit
|
||||||
only covers the graceful path). When run standalone from a terminal, stdin is
|
only covers the graceful path). When run standalone from a terminal, stdin is
|
||||||
a TTY and this blocks harmlessly forever.
|
a TTY and this blocks harmlessly forever.
|
||||||
|
|
||||||
|
NOT on Windows: there a read left pending on the stdin pipe stalls loading
|
||||||
|
scipy's OpenBLAS DLL in any other thread, forever — so the first analysis
|
||||||
|
hung the packaged app (dev runs no watcher). Measured 2026-10-12 with plain
|
||||||
|
Python, through the CRT and through kernel32.ReadFile alike. Windows waits
|
||||||
|
on the parent PROCESS instead, which also covers a crash.
|
||||||
"""
|
"""
|
||||||
|
if sys.platform == "win32":
|
||||||
|
_wait_for_parent_process()
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
while sys.stdin.buffer.read(1):
|
while sys.stdin.buffer.read(1):
|
||||||
pass
|
pass
|
||||||
@@ -38,6 +47,19 @@ def _watch_parent_and_exit() -> None:
|
|||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def _wait_for_parent_process() -> None:
|
||||||
|
"""Block until the process that started us exits (Windows only)."""
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
||||||
|
kernel32.OpenProcess.restype = ctypes.c_void_p
|
||||||
|
kernel32.WaitForSingleObject.argtypes = (ctypes.c_void_p, ctypes.c_uint32)
|
||||||
|
synchronize, infinite = 0x00100000, 0xFFFFFFFF
|
||||||
|
handle = kernel32.OpenProcess(synchronize, False, os.getppid())
|
||||||
|
if handle: # None: the parent is already gone
|
||||||
|
kernel32.WaitForSingleObject(handle, infinite)
|
||||||
|
|
||||||
|
|
||||||
def _release_remote() -> None:
|
def _release_remote() -> None:
|
||||||
"""Hand back a remote library's session on the way out, so the next
|
"""Hand back a remote library's session on the way out, so the next
|
||||||
computer opens it at once instead of waiting out the lease (or being asked
|
computer opens it at once instead of waiting out the lease (or being asked
|
||||||
|
|||||||
Reference in new issue
Block a user