Fix double ctrl-c kill (#2634)
This commit is contained in:
@@ -40,7 +40,7 @@ class WorkerManager:
|
||||
self.monitor_publisher, self.monitor_subscriber = monitor_pubsub
|
||||
self.worker_state = worker_state
|
||||
self.worker_state[self.MAIN_IDENT] = {"pid": self.pid}
|
||||
self.terminated = False
|
||||
self._shutting_down = False
|
||||
self._serve = serve
|
||||
self._server_settings = server_settings
|
||||
self._server_count = count()
|
||||
@@ -116,10 +116,9 @@ class WorkerManager:
|
||||
self.join()
|
||||
|
||||
def terminate(self):
|
||||
if not self.terminated:
|
||||
if not self._shutting_down:
|
||||
for process in self.processes:
|
||||
process.terminate()
|
||||
self.terminated = True
|
||||
|
||||
def restart(
|
||||
self,
|
||||
@@ -257,7 +256,7 @@ class WorkerManager:
|
||||
raise ServerKilled
|
||||
|
||||
def shutdown_signal(self, signal, frame):
|
||||
if self.terminated:
|
||||
if self._shutting_down:
|
||||
logger.info("Shutdown interrupted. Killing.")
|
||||
with suppress(ServerKilled):
|
||||
self.kill()
|
||||
@@ -270,6 +269,7 @@ class WorkerManager:
|
||||
for process in self.processes:
|
||||
if process.is_alive():
|
||||
process.terminate()
|
||||
self._shutting_down = True
|
||||
|
||||
@property
|
||||
def pid(self):
|
||||
|
||||
Reference in New Issue
Block a user