You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Process manager does not react to SIGTERM while a reload waits on a worker that does not exit #733
After its terminal closes, the worker process manager can stay alive and then not react to SIGTERM. We saw the symptom on macOS; the cause below comes from reading the source, and we have not built a minimal reproduction yet.
Version
taskiq 0.12.4, Python 3.14, macOS. The same code is on master today (taskiq/cli/worker/process_manager.py, ReloadOneAction.handle).
What we saw
taskiq worker module:broker -w 1 runs in a terminal.
The terminal is closed. The manager keeps running (SIGHUP is the documented "reload" signal, so this part is by design).
A later plain kill <manager pid> (SIGTERM) does not stop the manager. Only SIGKILL does, and the non-daemon worker child is then left behind.
What the source says
The SIGHUP handler puts ReloadAllAction on the action queue, which becomes one ReloadOneAction per worker.
ReloadOneAction.handle calls worker.terminate() and then worker.join() with no timeout.
The SIGTERM and SIGINT handlers only put ShutdownAction on the same queue. The main loop reads the queue between actions.
So while a reload waits in join() on a worker that does not exit after terminate(), a ShutdownAction is never read, and the manager looks deaf to SIGTERM. A worker that does not wake on the signal (for example the idle-listen case of Idle worker doesn't stop on SIGTERM without uvloop #722) is one way to get there.
Expected
SIGTERM stops the manager in bounded time, also during a reload.
Possible fix
Give the join() in ReloadOneAction.handle a timeout (for example the shutdown timeout) and kill the child after it, or check the queue for a ShutdownAction while it waits. I can open a PR for either if one of them fits.
A side question, not part of this report: when the manager's controlling terminal goes away, a reload is rarely what the user wants; would a stop be a better default there?
Activity