0

I have two celery tasks task1 and task2 which write to database. The third task task3 reads from the same database. task1 and task2 can run in parallel. task3 will run after both task1 and task2 have run.

I have looked at groups, chains and chords but can't get around to a place where I can run task3 without passing the arguments of task1 and task2 to it. I just want the sequence to be maintained

Any help in this direction is highly appreciated. Basically to run xsquare task at the last

@app.task
def xsum():
    return sum(i + i for i in range(100))

@app.task
def xmult():
    return sum(i * i for i in range(100))

@app.task
def xsquare():
    return sum(i * i for i in range(100))

xsum_mult = group(xsum.s(), xmult.s())

xsum_mult.apply_async()

# now run xsquare task

1 Answer 1

1

It should be as simple as using the immutable signatures. Scroll down to "The Primitives" section and you will see how to use immutable signatures in a chain.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this. Basically I have just started ignoring the arguments being passed, but this should resolve as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.