Skip to content

Commit

Permalink
Kill the entire process group if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Dec 16, 2024
1 parent 0cc7076 commit 515198b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sanic/worker/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ def kill(self):
for process in self.processes:
logger.info("Killing %s [%s]", process.name, process.pid)
with suppress(ProcessLookupError):
os.kill(process.pid, SIGKILL)
try:
os.killpg(os.getpgid(process.pid), SIGKILL)
except OSError:
os.kill(process.pid, SIGKILL)
raise ServerKilled

def shutdown_signal(self, signal, frame):
Expand All @@ -381,6 +384,7 @@ def shutdown_signal(self, signal, frame):
logger.info("Shutdown interrupted. Killing.")
with suppress(ServerKilled):
self.kill()
return

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

0 comments on commit 515198b

Please sign in to comment.