I am pretty new to celery and django in general so please excuse my lack of knowledge. I am trying to run a test to do some calculations and wait for the test to finish so that I can make sure it is done for the correct answers.
Here is what i have:
In app/tests.py
from tasks import *
c = calculate.apply_async(args=[1])
# wait until the task is done
while not calculate.AsyncResult(c.id).status == "SUCCESS":
print c.state
pass
in app/tasks.py
from celery import shared_task
@shared_task
def calculate(proj_id):
#some calculations followed by a save of the object
The state never changes from pending even though in the celery log it says that the task was completed successfully
[2014-06-10 17:55:11,417: INFO/MainProcess] Received task: app.tasks.calculate[1f11e7ab-0add-42df-beac-3d94c6868aac]
[2014-06-10 17:55:11,505: INFO/MainProcess] Task app.tasks.calculate[1f11e7ab-0add-42df-beac-3d94c6868aac] succeeded in 0.0864518239978s: None
I have also put CELERY_IGNORE_RESULT = False in the mainapp/settings.py, but this did not seem to do anything.
BROKER_URL = "amqp://the ipadress" CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend' CELERY_ACCEPT_CONTENT = ['json','pickle','msgpack','yaml'] CELERY_IGNORE_RESULT = False