Skip to content

Commit a13176b

Browse files
cyderizeDekker1
authored andcommitted
Use named pipe to terminate MiniZinc on Windows
Uses the same approach that the MiniZinc IDE uses to terminate MiniZinc on Windows, by writing to a named pipe created by MiniZInc. Fixes #191
1 parent 45fabec commit a13176b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/minizinc/instance.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,11 @@ async def solutions(
661661
# an unexpected Python exception occurred
662662
# First, terminate the process
663663
if sys.platform == "win32":
664-
import signal
665-
666-
proc.send_signal(signal.CTRL_C_EVENT)
664+
with open(
665+
f"\\\\.\\pipe\\minizinc-{proc.pid}", mode="w"
666+
) as named_pipe:
667+
# Trigger MiniZinc termination
668+
named_pipe.write("")
667669
else:
668670
proc.terminate()
669671
_ = await proc.wait()

0 commit comments

Comments
 (0)