Reputation: 95
right now i am implementing celery tasks in my appplication. I want that my task perform chaining But somehow, the chain doesn't work, the group work but the chain doesn't work. The process that I want is I want that the GROUP_A will be processed after i process the GROUP_B and so on. I have tried using chord but still got no idea. Below is my simple chain performing group task in celery. Thank for your attention guys.
GROUP_A = []
GROUP_B = []
GROUP_C = []
GROUP_D = []
for i in range(3):
GROUP_A.append(A.s(i+1))
GROUP_B.append(B.s(i+1))
GROUP_C.append(C.s(i+1))
GROUP_D.append(D.s(i+1))
job = chain(
group(GROUP_A),
group(GROUP_B),
group(GROUP_C),
group(GROUP_D)
)
job.apply_async()
Regards,
Meikelwis Wijaya
Upvotes: 1
Views: 1000
Reputation: 15926
The issue that you have is that you have to get the immutable signature of each group when you pass them up into a subsequent chain because each group is itself a task (and not an invocation of a task):
job = chain(
group(GROUP_A).si(),
group(GROUP_B).si(),
group(GROUP_C).si(),
group(GROUP_D).si()
)
job.apply_async()
Upvotes: 2
Reputation: 1669
Not sure I understand in full, but when you call tasks with s() they will pass on their results.
In your case for task A you are executing 3 parallel tasks (the group) with nothing passed in, and feeding that to the B task's group.
Not really sure what you are trying to achieve bit if you want just to chain them a simple
chain([D.si(i, 1), C.s(1), B.s(1), A.s(1)])
Should do, provided that the tasks all accept 2 arguments
Upvotes: 0