I'd like to quit a celery task gracefully (i.e. not by calling revoke(celery_task_id, terminate=True)
). I thought I'd send a message to the task that sets a flag, so that the task function can return. What's the best way to communicate with a task?
Use signals for this. Celery's revoke
is the right choice; it uses SIGTERM by default, but you can specify another using the signal
argument, if you prefer.
Just set a signal handler for it in your task (using the signal
module) that terminates the task gracefully.