Reputation: 363
Suppose i have a celery code like this:
@celery.task()
def A(a):
try:
.......
.......
except Exception,e:
raise
@celery.task()
def B(b):
try:
.......
.......
except Exception,e:
raise
def C(c):
try:
.......
.......
except Exception,e:
raise
def final():
callback = C.s()
header = [A.s(something), B.s(something)]
result = chord(header)(callback)
result.get()
Now when i try to run the task final() i always get an error like C.s() takes exactly 1 argument (2 given)
because callback is applied with the return value of each task in the header. so how can i fix this so that the task C() runs fine????
Upvotes: 1
Views: 1477
Reputation: 5195
You can use immutable tasks to make independant tasks and not forward the result.
def final():
# C needs an argument, note the use of the shortcut `si`
callback = C.si(something)
header = [A.s(something), B.s(something)]
result = chord(header)(callback)
result.get()
As a completely side-note, the use of except Exception as e
is preferred if you're running Python 2.6+ or required for Python 3.x (see here for more details).
Upvotes: 2