7

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.

RemcoGerlich
  • 30,470
  • 6
  • 61
  • 79

2 Answers2

7

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
fedorqui
  • 275,237
  • 103
  • 548
  • 598
scytale
  • 12,346
  • 3
  • 32
  • 46
3

From Canvas documentation:

  • group

The group primitive is a signature that takes a list of tasks that should be applied in parallel.

  • chain

The chain primitive lets us link together signatures so that one is called after the other, essentially forming a chain of callbacks.

  • chord

A chord is just like a group but with a callback. A chord consists of a header group and a body, where the body is a task that should execute after all of the tasks in the header are complete.

Aymen Alsaadi
  • 1,329
  • 1
  • 11
  • 12