python - How to add a task to a group in Celery? -
i want incrementally build group of celery tasks in code because creating tasks based on logic in loop.
for example:
my_group = group() item in items: if item.is_special(): # doesn't work... my_group.add(special_processing.s(item.id)) else: my_group.add(regular_processing.s(item.id)) res = my_group() i've read groups partials, good, how combine partials form group?
a simple way i've found far create list of tasks, , convert group.
so:
tasks = [] item in items: if item.is_special(): tasks.append(special_processing.s(item.id)) else: tasks.append(regular_processing.s(item.id)) res = group(*tasks) i haven't tested yet, i'll update answer if doesn't work.
Comments
Post a Comment