Skip to content

Commit 106b57a

Browse files
committed
Fix windows
1 parent adbdb77 commit 106b57a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

ipykernel/kernelbase.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
import warnings
1717
from datetime import datetime
1818
from functools import partial
19-
from signal import (SIGINT, SIGKILL, SIGTERM, Signals, default_int_handler,
20-
signal)
19+
from signal import SIGINT, SIGTERM, Signals, default_int_handler, signal
20+
21+
if sys.platform != "win32":
22+
from signal import SIGKILL
23+
else:
24+
SIGKILL = None
25+
2126

2227
try:
2328
import psutil
@@ -1149,9 +1154,10 @@ async def _progressively_terminate_all_children(self):
11491154
await asyncio.sleep(0.05)
11501155
self.log.debug("Sending SIGTERM to {pgid=}")
11511156
os.killpg(pgid, SIGTERM)
1152-
await asyncio.sleep(0.05)
1153-
self.log.debug("Sending SIGKILL to {pgid=}")
1154-
os.killpg(pgid, SIGKILL)
1157+
if sys.platform != "win32":
1158+
await asyncio.sleep(0.05)
1159+
self.log.debug("Sending SIGKILL to {pgid=}")
1160+
os.killpg(pgid, SIGKILL)
11551161
except Exception:
11561162
self.log.exception("Exception during subprocesses termination")
11571163
return
@@ -1163,7 +1169,12 @@ async def _progressively_terminate_all_children(self):
11631169
return
11641170
self.log.debug(f"Trying to interrupt then kill subprocesses : {children=}")
11651171
self._send_interupt_children()
1166-
for signum in (SIGTERM, SIGKILL):
1172+
if sys.platform != "win32":
1173+
sigs = (SIGTERM, SIGKILL)
1174+
else:
1175+
sigs = SIGTERM
1176+
1177+
for signum in sigs:
11671178
self.log.debug(
11681179
f"Will try to send {signum} ({Signals(signum)}) to subprocesses :{children}"
11691180
)

0 commit comments

Comments
 (0)