How is single-worker recycling supposed to work after max_tasks_per_child is reached? #608
Replies: 1 comment
|
I traced this through the code and reproduced the behavior locally, so here is what actually happens and where the hang lives. The respawn machinery in core worksWhen
I verified this end to end with a minimal custom broker (yields N messages, then holds the connection open like a real broker) run with The reported hang starts below coreIn your logs the last worker line is "Shutting down the broker.", and the process stays alive, so the hang is inside or after
In both cases How to tell which one you are hittingWith the real taskiq-redis setup, run
Design question for the maintainersIndependent of what taskiq-redis does, should the worker child guarantee its own exit after a graceful shutdown, the way gunicorn workers do? For example, after |
Uh oh!
There was an error while loading. Please reload this page.
I am trying to understand the intended worker recycle/restart model. From reading the worker, receiver, and process manager code, this is how it looks to me:
max_tasks_per_childis reached, the worker stops prefetching, waits for running tasks to finish, and goes through shutdown, but the process itself does not exitWhat I want to clarify is how restarting a single worker is supposed to work. As far as I can tell:
SIGINT/SIGTERMare shutdown signals, not restart signalsSIGHUPreloads all workersReloadOneActionrestarts one worker, but I do not see a supported way to trigger that for a specific worker from within worker codeRight now, the only way I was able to make a specific worker get recycled was to add
os._exit(1)in the worker shutdown path so the process exits and the manager respawns it. So my questions are:max_tasks_per_childis reached, is the intended behavior that the worker only goes through shutdown, or that the worker process exits and the parent respawns it?os._exit(1)?My use case is that I do not want to restart all workers. I want to recycle a specific worker once
max_tasks_per_childis reached.All reactions