I am using celery chain
in Django project.
For chained tasks, I am using task_postrun
signal to revoke all subsequent tasks similar to this.
@task_postrun.connect
def task_postrun_handler(
signal, sender, task_id, task, retval, state, args, kwargs, **kwds
):
# do other things first
if retval != 1:
task.request.chain[:] = []
So if the task's return value is not 1, then revoke all the subsequent tasks. It works fine.
However, in my test, I run the tasks in eager mode. It does enter the
task_postrun_handler
, but doesn't have array of chain
( the callbacks
is None
as well).
In this way, I am not able to terminate the task chains in my test.
I tried both in celery 3.1.23
and celery 4.0.2
Thanks for any help.