Search code examples
djangostatecelerycelery-task

Best way to query Celery using AJAX from front-end to know if a created task is completed or not?


I am using Django with Celery + RabbitMQ to create video conversion tasks of videos being uploaded by the users. Now I know how to query celery to get the status. My question is where to save the task_id associated with each task, should I save it in models or in django's cache?

I know that similar questions have been asked in the past e.g. this stackoverflow question but there has been no definitive answer yet. I know the answer to this varies per developer's preferences but if someone can educate on pros/cons of different approaches, that will be great.

Just to re-iterate I will use the task_id to fire AJAX queries every so often from the front-end to know if the video conversion is completed or not.


Solution

  • Refer to my answer on your linked question: Test if a celery task is still being processed

    So after setting the celery_task field, you could easily define a ajax view which would return the task status in a required format.