Celery 3.0
broker=RabbitMQ
Tasks have already been acknowledged and started processing, and have state=STARTED
. Then I want to restart my worker (to update the worker to a newer version). After restart worker (using supervisorctl restart
), those long running tasks are all been terminated. But their states remain in state=STARTED
. How can I update their state to FAILURE
or whatever other values? (And, I don't want these tasks being executed again after the worker restarts.)
track_started=True
--- If with this option, the tasks stay at state=STARTED
after the worker restarts. If without this option, the tasks stay at state=PENDING
after the worker restarts. CELERY_ACKS_LATE=True
--- The tasks stay at state=STARTED
after the worker restarts. And tasks are executed again, not a desired behavior.signal(SIGTERM, handler)
and a handler function to catch the signal. The handler can successfully be entered. However, no matter what thing I put inside the handler, it can't change the task's state. The states just stay as the same and won't change to FAILURE
. Inside the handler I've tried
raise Exception
exit(0)
exit(1)
Is there any settings of Celery that could enable it to track the state of task being shutdown?
You need to revoke the tasks on worker shutdown. Take a look at this issue for the actual code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With