16
16
import warnings
17
17
from datetime import datetime
18
18
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
+
21
26
22
27
try :
23
28
import psutil
@@ -1149,9 +1154,10 @@ async def _progressively_terminate_all_children(self):
1149
1154
await asyncio .sleep (0.05 )
1150
1155
self .log .debug ("Sending SIGTERM to {pgid=}" )
1151
1156
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 )
1155
1161
except Exception :
1156
1162
self .log .exception ("Exception during subprocesses termination" )
1157
1163
return
@@ -1163,7 +1169,12 @@ async def _progressively_terminate_all_children(self):
1163
1169
return
1164
1170
self .log .debug (f"Trying to interrupt then kill subprocesses : { children = } " )
1165
1171
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 :
1167
1178
self .log .debug (
1168
1179
f"Will try to send { signum } ({ Signals (signum )} ) to subprocesses :{ children } "
1169
1180
)
0 commit comments