jmizgajski
5/10/2014 - 1:28 PM

Chaining two groups of tasks in celery.

Chaining two groups of tasks in celery.

#task is a task that is not interested in any results from other tasks
#callback is a task you want to call after each group is finished (ex. log time)
# and has to take a list of results as first arguement 

@app.task(base=Task)
def task(i):
  #do stuff
  pass

@app.task(base=Task)
def callback(results):
  #do stuff with results i.e. log total time of distributed processing
  pass


chain(
    chord([task.si(x) for x in [1,2,3]], body=callback.s(), immutable=True),
    chord([task.si(x) for x in [5,6,7]], body=callback.s(), immutable=True)
  )