You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested chord are failling with KeyError, if inner chord consists of one task #3885
I have the following set of tasks, nested chord of chords. One inner chord has only one task (i don't know exact number of tasks beforehand, they are compound in runtime). And it is falling with exception KeyError: 0
Traceback (most recent call last):
File "<console>", line 6, in <module>
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 182, in delay
return self.apply_async(partial_args, partial_kwargs)
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 1245, in apply_async
return self.run(tasks, body, args, task_id=task_id, **options)
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 1287, in run
result=results)
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/backends/redis.py", line 245, in apply_chord
return header(*partial_args, **options or {})
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 962, in __call__
return self.apply_async(partial_args, **options)
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 987, in apply_async
args=args, kwargs=kwargs, **options))
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 1063, in _apply_tasks
**options)
File "/home/maksym/projects/python_ve/lib/python3.4/site-packages/celery/canvas.py", line 1242, in apply_async
return (self.tasks[0] | body).set(task_id=task_id).apply_async(
KeyError: 0
I assume self.task[0] should be replaced with self.task, am i right?
I think this may be the key. I dynamically generate my chords and they may have anywhere from 1-∞ members, and I noticed that when the chord has only one member, the result is not passed to the callback wrapped in a list.
Upon looking at the release notes, I discovered the following:
A chord where the header group only consists of a single task is now turned into a simple chain.
I think this conversion is failing to wrap the result in a list as would happen if there were multiple tasks in the header. If your callback code is expecting to handle that list, you would run into errors. Complicating matters is the case (like mine) where the chord task result is itself a list.
Not sure if this specific finding has been reported elsewhere, I found this bug in that search.
Activity
thedrow commentedon Apr 15, 2017
@robpogorzelski Do you mind describing your approach? I'll see if I can give it a go...
e3b0c442 commentedon May 26, 2017
I think this may be the key. I dynamically generate my chords and they may have anywhere from 1-∞ members, and I noticed that when the chord has only one member, the result is not passed to the callback wrapped in a list.
Upon looking at the release notes, I discovered the following:
I think this conversion is failing to wrap the result in a list as would happen if there were multiple tasks in the header. If your callback code is expecting to handle that list, you would run into errors. Complicating matters is the case (like mine) where the chord task result is itself a list.
Not sure if this specific finding has been reported elsewhere, I found this bug in that search.
Fix length-1 and nested chords (#4393 #4055 #3885 #3597 #3574 #3323) (#…
JioHooney commentedon Feb 13, 2018
I have same problem.
Has this problem been resolved?
thedrow commentedon Feb 13, 2018
Yes in master. Release is coming soon. See #4387 for details.
JioHooney commentedon Feb 13, 2018
@thedrow
Thanks for the answer
added new regression test to check issue #3885 (#10622)
added new regression test to check issue celery#3885 (celery#10622)