From 064168f3c8f00b380c5fc8325d8b2b84d2299212 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Wed, 14 Dec 2022 23:51:11 +0200 Subject: [PATCH] Add a SIGKILL to second ctrl+c (#2621) --- sanic/worker/manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sanic/worker/manager.py b/sanic/worker/manager.py index 3af9fa97..2f09b818 100644 --- a/sanic/worker/manager.py +++ b/sanic/worker/manager.py @@ -1,5 +1,6 @@ import os +from contextlib import suppress from itertools import count from random import choice from signal import SIGINT, SIGTERM, Signals @@ -92,7 +93,6 @@ class WorkerManager: self.monitor() self.join() self.terminate() - # self.kill() def start(self): for process in self.processes: @@ -238,6 +238,11 @@ class WorkerManager: raise ServerKilled def shutdown_signal(self, signal, frame): + if self.terminated: + logger.info("Shutdown interrupted. Killing.") + with suppress(ServerKilled): + self.kill() + logger.info("Received signal %s. Shutting down.", Signals(signal).name) self.monitor_publisher.send(None) self.shutdown()