3
@shared_task
def process_record(x):
    return [1,2,4,4,5,6]

@shared_task
def add(pro_id):
    return pro_id + 10


@shared_task
def dmap(it, callback):
    callback = subtask(callback)
    group_args = [callback.clone([arg,]) for arg in it]
    return group(group_args)()

ch = (process_record.s(10) | dmap.s(add.s()))
ch.apply_async()

the above code works fine, for the above two tasks. Now, I need to add more task which is to be called after add (with its return value) task.

@shared_task
def mul(add_id):
    return add_id * 2

I have tired ch = (process_record.s(10) | dmap.s(add.s()) | mul.s()) it does not work since return type from add is GroupResult.

How can mul task can be chained at end ?

resource: How to chain a Celery task that returns a list into a group?

navyad
  • 3,752
  • 7
  • 47
  • 88
  • https://gist.github.com/navyad/f72f5facb317c68bb57962cf1266af7d#gistcomment-3636331 Has worked for me. – navyad May 15 '21 at 08:58
  • 1
    Please add some details, here or in the gist. For newbies like it is really time consuming to understand what was your point and why that way. Providing some links to the official doc and then just some details on what you've done can illuminates a lot of confusion. – Kasir Barati Jul 07 '22 at 12:57

0 Answers0