-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restart a consumer after a certain number of tasks #261
Comments
Right now there is not, but I don't see why we should implement a restart signal at the very least. |
You mean why a signal? It's a common technique, afaik.
http://docs.celeryproject.org/en/latest/userguide/workers.html#restarting-the-worker
I could be wrong.
On Oct 8, 2017 19:17, "Charles Leifer" <notifications@github.com> wrote:
Right now there is not, but I don't see why we should implement a restart
signal at the very least. SIGHUP for instance?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#261 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQXVTwK3nzDuL0lJ1Iur-jd8NblkuRRJks5sqPV9gaJpZM4Pxn4M>
.
|
I'm suggesting using SIGHUP to trigger a restart. I'm not too sure how to restart processes with Python from within the process itself... is it sufficient to restart the workers or should the whole consumer process get restarted, for example? Would I use the os.exec family to start the new process? |
Looks like I want https://docs.python.org/3/library/os.html#os.execl |
Wanna try out 1ffb3dd ? |
If I understood correctly, if the master process receives SIGHUP, it restart itself with all the workers. If a worker receives SIGHUP, only it restarts. I am interested in the second case, because other workers could be ok. |
Will try this later. Thank you! |
I did not implement this on a worker-by-worker basis. It applies to the consumer as a whole. |
If you're running the worker health checker, it should be possible to just kill the worker process using the standard |
This should work. If health checker always running? |
Looks like it is. This means that all I need is there in place already. I can count number of tasks and raise KeyboardInterrupt when I think the worker should restart. It will die and the consumer will raise another worker in its place? |
Is it easy to implement something like http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-worker_max_tasks_per_child ?
Or if there was a mechanism to restart the consumer manually ( #251 ) it should be easy to count tasks by myself and decide whether I need to restart the consumer because of leaking memory.
The text was updated successfully, but these errors were encountered: