0

I have a complicated scenario I need to tackle.

I'm using Celery to run tasks in parallel, my tasks involve with HTTP requests and I'm planning to use Celery along with eventlet for such purpose.

Let me explain my scenario:

I have 2 tasks that can run in parallel and third task that needs to work on the output of those 2 tasks therefore I'm using Celery group to run the 2 tasks and Celery chain to pass the output to the third task to work on it when they finish.

Now it gets complicated, the third task needs to spawn multiple tasks that I would like to run in parallel and I would like to collect all outputs together and to process it in another task.

So I created a group for the multiple tasks together with a chain to process all information.

I guess I'm missing basic information about Celery concurrent primitives, I was having a 1 celery task that worked well but I needed to make it faster.

This is a simplified sample of the code:

@app.task
def task2():
       return "aaaa"

@app.task
def task3():
       return "bbbb"

@app.task
def task4():
    work = group(...) | task5.s(...)                                                          
    work()

@app.task
def task1():   
        tasks = [task2.s(a, b), task3.s(c, d)]
    work = group(tasks) | task4.s()
    return work()

This is how I start this operation:

    task = tasks1.apply_async(kwargs=kwargs, queue='queue1')

I save task.id and pull the server every 30 seconds to see if results available by doing:

results = tasks1.AsyncResult(task_id)
if results.ready():
     res = results.get()
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
DjangoPy
  • 855
  • 1
  • 13
  • 29
  • 1
    So what is your question? – temoto Aug 12 '14 at 08:16
  • This is not working. How to make it work? – DjangoPy Aug 12 '14 at 18:13
  • 1
    You have put an effort to explain in detail what you are doing. It would be a shame to not get a helpful answer because it's hard to understand what exactly is wrong. Now please make the issue more clean than "not working". This reading may help: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html – temoto Aug 13 '14 at 22:09

0 Answers0