Skip to content

Canvas: Allow the same Signature to trigger two Chords #4562

Open

Description

@alanjds

Questions:

  1. Can a Task trigger 2 Chords?
  2. If not, how to implement the following graph on Celery?

Take a look on the C1 node on such graph to be described via Canvas primitives:

start -> B1
start -> C1 
start -> D1

C1 -> E2
D1 -> E2

C1 -> F2
B1 -> F2

F2 -> end
E2 -> end

Steps to reproduce

I could create such Canvas via code, assuming b1, c1, d1, e2, f2 are Celery instances of myfunc task:

b1 = myfunc.s()
c1 = myfunc.s()
d1 = myfunc.s()
e2 = myfunc.s()
f2 = myfunc.s()

depends_of_e2 = chord([b1, c1], e2)
depends_of_f2 = chord([c1, d1], f2)

depends_of_e2.delay()
depends_of_f2.delay()

This is wrong because C1 will run twice! I need it to run only once.
B1, C1 and D1 should start at the same time.
I can workaround by freezing C1 signature before passing to the chords:

...
c1 = myfunc.s()
c1.freeze()
...

However, the tasks can trigger only one Chord on completion, from the code I saw up to now.
Is there a way that I had not found yet?

Expected behavior

  1. B1, C1 and D1 starts
  2. On B1 and C1 finished, E2 starts
  3. On D1 and C1 finished, F2 starts

Actual behavior

  1. B1, C1, D1 starts
  2. Another C1 starts
  3. On B1 and first C1 finished, E2 starts
  4. On D1 and second C1 finished, F2 starts

Checklist

  • Celery version:
$ celery --version
4.1.0 (latentcall)
  • I have verified that the issue exists against the master branch of Celery.

Activity

  1. alanjds commented on Feb 27, 2018

    @alanjds
    ContributorAuthor

    Just found that I may not be the 1st to ask for it: #893

  2. miksyn commented on Mar 7, 2018

    @miksyn

    U can use two another patterns. First slower than expects (F2 executes after E2), but can be implemented only on celery canvases.
    2
    Second has expected execution time, but more difficult in code: need catch results of first group and send new group task.
    1

  3. alanjds commented on Mar 7, 2018

    @alanjds
    ContributorAuthor

    @2miksyn You are right, it is possible. However, not always applicable.

    I am talking about very long tasks. For exemple, if D and F takes about 5h and B and E takes only 1h, then the total time goes from 6h to 11 on your 1st proposal, and to 10 on the 2nd proposal.

    Even it was about little tasks, this means the full DAG taking from 600ms to 1sec, only on this exemple. Its a lot and can be worst, depending on your scenario.

  4. added this to the v4.3 milestone on Aug 10, 2018
  5. modified the milestones: v4.3, v5.0.0 on Nov 17, 2018
  6. modified the milestones: v5.0.0, 4.7 on Jul 6, 2019
  7. modified the milestones: 4.7, v5.0.0 on Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions