Search code examples
celery

Avoiding duplicate tasks in celery broker


I want to create the following flow using celery configuration\api:

  • Send TaskA(argB) Only if celery queue has no TaskA(argB) already pending

Is it possible? how?


Solution

  • I cannot think of a way but to

    1. Retrieve all executing and scheduled tasks via celery inspect

    2. Iterate through them to see if your task is there.

    check this SO question to see how the first point is done.

    good luck