Skip to content

Commit 79a7f21

Browse files
authored
Kill the entire process group if applicable (#3015)
* Cleanup some typing * Kill the entire process group if applicable * Revert path change * Disable broken reloader tests
1 parent 665234d commit 79a7f21

4 files changed

Lines changed: 257 additions & 238 deletions

File tree

sanic/worker/manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ def kill(self):
372372
for process in self.processes:
373373
logger.info("Killing %s [%s]", process.name, process.pid)
374374
with suppress(ProcessLookupError):
375-
os.kill(process.pid, SIGKILL)
375+
try:
376+
os.killpg(os.getpgid(process.pid), SIGKILL)
377+
except OSError:
378+
os.kill(process.pid, SIGKILL)
376379
raise ServerKilled
377380

378381
def shutdown_signal(self, signal, frame):
@@ -381,6 +384,7 @@ def shutdown_signal(self, signal, frame):
381384
logger.info("Shutdown interrupted. Killing.")
382385
with suppress(ServerKilled):
383386
self.kill()
387+
return
384388

385389
logger.info("Received signal %s. Shutting down.", Signals(signal).name)
386390
self.monitor_publisher.send(None)

0 commit comments

Comments
 (0)