2

I have error when i am trying to use chord to send a task after all the tasks have been sent.

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/wenzhixue/projects/workspace/fallfor_core/twitter/tasks.py", line 13, in bulk_change_bio
    chord([change_bio_task.delay(account,'http://fallfor.com') for account in account_list ])(shutdown.s(c))
  File "/Library/Python/2.7/site-packages/celery/canvas.py", line 470, in __call__
    _chord = self.type
  File "/Library/Python/2.7/site-packages/celery/canvas.py", line 467, in type
    return self._type or self.tasks[0].type.app.tasks['celery.chord']
AttributeError: 'AsyncResult' object has no attribute 'type'

-

@task()
def shutdown(ec2):
    print "shutting down!!!!"
    time.sleep(300)
    return True

c = Ec2()
account_list = Account.objects.all()
chord([change_bio_task.delay() for account in account_list ])(shutdown.s(c))

1 Answer 1

4

Chord accepts two parameters: first one list of subtasks which is called as a group and second optional is subtask used as a callback after whole tasks from list are finished.

Example from API referance:

res = chord([add.s(2, 2), add.s(4, 4)])(sum_task.s())

In your code you are passing as a first parameter list of AsyncResults not subtasks. This should be correct:

chord([change_bio_task.s() for account in account_list ])(shutdown.si(c))

Take a look that I changed shutdown.s(c) to shutdown.si(c) which is immutable and ignores results returned finished change_bio_task.

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

Comments

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.