From 904d5b56936f4b90fa6ffb4d5bc694ecc2a27a67 Mon Sep 17 00:00:00 2001 From: jimi <1847930177@qq.com> Date: Sun, 1 Mar 2026 17:13:56 +0800 Subject: [PATCH] fix: make coordinator shutdown signal handling idempotent --- scripts/multi_process_launcher.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/multi_process_launcher.py b/scripts/multi_process_launcher.py index 46cfe0b..1e6688f 100644 --- a/scripts/multi_process_launcher.py +++ b/scripts/multi_process_launcher.py @@ -84,6 +84,7 @@ class Coordinator: self.num_workers = num_workers or max(2, cpu_count()) self.workers: List[WorkerProcess] = [] self.running = False + self._stopping = False self.enable_agent = enable_agent def _get_shard_key(self, acc_id: str, from_id: str) -> int: @@ -153,11 +154,17 @@ class Coordinator: def _signal_handler(self, signum, frame): """信号处理""" + if self._stopping: + return + self._stopping = True logger.info(f"收到信号 {signum},正在停止所有工作进程...") self.stop() def stop(self): """停止所有工作进程""" + if self._stopping and not self.running and not any(w.process and w.process.is_alive() for w in self.workers): + return + self._stopping = True self.running = False for worker in self.workers: