@@ -802,13 +802,11 @@ async def comm_info_request(self, stream, ident, parent):
802
802
self .log .debug ("%s" , msg )
803
803
804
804
def _send_interupt_children (self ):
805
-
806
- pid = os .getpid ()
807
- pgid = os .getpgid (pid )
808
-
809
805
if os .name == "nt" :
810
806
self .log .error ("Interrupt message not supported on Windows" )
811
807
else :
808
+ pid = os .getpid ()
809
+ pgid = os .getpgid (pid )
812
810
# Prefer process-group over process
813
811
if pgid and hasattr (os , "killpg" ):
814
812
try :
@@ -1139,6 +1137,9 @@ def _input_request(self, prompt, ident, parent, password=False):
1139
1137
return value
1140
1138
1141
1139
async def _progressively_terminate_all_children (self ):
1140
+ if sys .platform != "win32" :
1141
+ self .log .info (f"Terminating subprocesses not yet supported on windows." )
1142
+ return
1142
1143
1143
1144
pgid = os .getpgid (os .getpid ())
1144
1145
if not pgid :
@@ -1152,10 +1153,9 @@ async def _progressively_terminate_all_children(self):
1152
1153
await asyncio .sleep (0.05 )
1153
1154
self .log .debug ("Sending SIGTERM to {pgid}" )
1154
1155
os .killpg (pgid , SIGTERM )
1155
- if sys .platform != "win32" :
1156
- await asyncio .sleep (0.05 )
1157
- self .log .debug ("Sending SIGKILL to {pgid}" )
1158
- os .killpg (pgid , SIGKILL )
1156
+ await asyncio .sleep (0.05 )
1157
+ self .log .debug ("Sending SIGKILL to {pgid}" )
1158
+ os .killpg (pgid , SIGKILL )
1159
1159
except Exception :
1160
1160
self .log .exception ("Exception during subprocesses termination" )
1161
1161
return
@@ -1167,12 +1167,8 @@ async def _progressively_terminate_all_children(self):
1167
1167
return
1168
1168
self .log .debug (f"Trying to interrupt then kill subprocesses : { children } " )
1169
1169
self ._send_interupt_children ()
1170
- if sys .platform != "win32" :
1171
- sigs = (SIGTERM , SIGKILL )
1172
- else :
1173
- sigs = SIGTERM
1174
1170
1175
- for signum in sigs :
1171
+ for signum in ( SIGTERM , SIGKILL ) :
1176
1172
self .log .debug (
1177
1173
f"Will try to send { signum } ({ Signals (signum )} ) to subprocesses :{ children } "
1178
1174
)
0 commit comments