Search code examples
pythoncelerycelery-canvas

With Celery Canvas, what is the difference between chord() and chain(group(), task)


We're implementing a workflow with Celery. First we need to run some tasks in parallel, and when they are all finished we need to run a single task.

It seems we can use chord, or group and chain:

chord(tasks, task)

vs

group(tasks) | task

What is the exact difference between those two? They seem to do the same thing.


Solution

  • The Canvas docs say:

    Chaining a group together with another task will automatically upgrade it to be a chord:

     >>> c3 = (group(add.s(i, i) for i in xrange(10)) | xsum.s())
    >>> res = c3()
    >>> res.get()
    90