I'm using celery, I have several tasks which needed to be executed in order.
For example I have this task:
@celery.task
def tprint(word):
print word
And I want to do something like this:
>>> chain(tprint.s('a') | tprint.s('b'))()
Then I get TypeError: tprint() takes exactly 1 argument (2 given)
.
The same with chord, in this situation which I need a task to be executed after a group of tasks:
>>> chord([tprint.s('a'), tprint.s('b')])(tprint.s('c'))
So how to deal with this situation? I don't care the result of each task, but they need to be executed in order.
Add a second parameter won't work:
@celery.task
def tprint(word, ignore=None):
print word
>>> chain(tprint.s('a', 0) | tprint.s('b'))()
This will print out 'a' and 'None'.
question from:
https://stackoverflow.com/questions/13629507/celery-how-to-ignore-task-result-in-chord-or-chain 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…