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
The worker_init signal works fine for me, but the worker_shutdown signal never seems to fire. I did a search on the code base and found the worker_init signal is sent in celery/apps/worker.py, but when I searched for worker_shutdown I can't find anywhere that it is actually sent.
It could maybe added in the _shutdown_handler function, but due to the asynchronous aspect of terminating workers I'm not sure if that is entirely correct. Perhaps an atexit handler needs to be registered somewhere to actually send the signal?
So I played around with this a bit more and I can see that sending the signal in _shutdown_handler means it can occur before all the worker processes are shutdown. An exception can be raised from _shutdown_handler or in the functions maybe_shutdown and consume_messages in consumer.py to actually shutdown the worker. Since it seems like there are multiple code paths for shutting down, I added an atexit handler to cover all cases that seems to work for me so far.
I registered the handler as part of install_platform_tweaks:
definstall_platform_tweaks(self, worker):
"""Install platform specific tweaks and workarounds."""# Register a handler to send a shutdown signal when the worker exitsimportatexitatexit.register(lambda*a, **kw: _on_worker_shutdown(worker))
Activity
chrisw1229 commentedon May 8, 2013
So I played around with this a bit more and I can see that sending the signal in _shutdown_handler means it can occur before all the worker processes are shutdown. An exception can be raised from _shutdown_handler or in the functions maybe_shutdown and consume_messages in consumer.py to actually shutdown the worker. Since it seems like there are multiple code paths for shutting down, I added an atexit handler to cover all cases that seems to work for me so far.
I registered the handler as part of install_platform_tweaks:
And then added a new shutdown function:
worker_shutdown signal no longer sent. Closes #1339
ask commentedon May 14, 2013
Try this patch plase!
chrisw1229 commentedon May 15, 2013
@ask This new patch is working fine for me so far, tested under Windows and Linux. Thanks!