views:

42

answers:

1

I`ve followed the guidelines in http://celeryq.org/docs/django-celery/getting-started/first-steps-with-django.html and created a view that calls my test method in tasks.py:

import time
from celery.decorators import task

@task()
def add(x, y):
    time.sleep(10)
    return x + y

But if my add-method takes a long time to respond, how can I store the result-object I got when calling add.delay(1,2) and use it to check the progress/success/result using get later?

A: 

You only need the task-id:

result = add.delay(2, 2)
result.task_id

With this you can poll the status of the task (using e.g. AJAX) Django-celery comes with a view that returns results and status in JSON: http://celeryq.org/docs/django-celery/reference/djcelery.views.html

asksol