Skip to content

Commit d5c8198

Browse files
committed
Fix: Handle missing worker processes on shutdown
Added exception handling for ProcessLookupError when killing worker processes during shutdown. Now logs if a process is already terminated, improving robustness and clarity in process management.
1 parent 96719c3 commit d5c8198

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

taskiq/cli/worker/process_manager.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,19 @@ def start(self) -> int | None: # noqa: C901
275275
logger.debug("Process manager closed, killing workers.")
276276
for worker in self.workers:
277277
if worker.pid:
278-
os.kill(worker.pid, signal.SIGINT)
278+
try:
279+
os.kill(worker.pid, signal.SIGINT)
280+
logger.info(
281+
"Stopped process %s with pid %s",
282+
worker.name,
283+
worker.pid,
284+
)
285+
except ProcessLookupError:
286+
logger.info(
287+
"Process %s (pid %s) already terminated",
288+
worker.name,
289+
worker.pid,
290+
)
279291
return None
280292

281293
for worker_num, worker in enumerate(self.workers):

0 commit comments

Comments
 (0)