Skip to content

Commit

Permalink
Kill the entire process group if applicable (#3015)
Browse files Browse the repository at this point in the history
* Cleanup some typing

* Kill the entire process group if applicable

* Revert path change

* Disable broken reloader tests
  • Loading branch information
ahopkins authored Dec 22, 2024
1 parent 665234d commit 79a7f21
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 238 deletions.
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
Loading

0 comments on commit 79a7f21

Please sign in to comment.