I need following workflow for my celery tasks.
when taskA finishes with success I want to execute taskB.
I know there is signal @task_success
but this returns only task's result, and I need access to parameters of previous task's arguments. So I decided for code like these:
@app.task
def taskA(arg):
# not cool, but... https://github.com/celery/celery/issues/3797
from shopify.tasks import taskA
taskA(arg)
@task_postrun.connect
def fetch_taskA_success_handler(sender=None, **kwargs):
from gcp.tasks import taskB
if kwargs.get('state') == 'SUCCESS':
taskB.apply_async((kwargs.get('args')[0], ))
The problem is the taskB
seems to be executed in some endless loop many, many times instead only once.