The best way to request celery using AJAX from the interface is to find out if the created task is complete or not?

I use Django with Celery + RabbitMQ to create conversion tasks for videos uploaded by users. Now I know how to request celery in order to get status. My question is where to save the task_id associated with each task, should I save it in models or in the django cache?

I know that similar questions have been asked in the past, for example, https://stackoverflow.com/a/167169/2/16/16/12/ , but there is no final answer yet. I know that the answer to this depends on the preferences of the developers, but if someone can bring up the pros and cons of different approaches, it will be great.

Just to re-iterate, I will use task_id to run AJAX requests from the front-end each time to find out if the video conversion is complete or not.

+4
source share
2 answers

Refer to my answer on a related question: Check if the celery assignment is still being processed

So, after setting the celery_task field, you can easily define an ajax representation that will return the status of the task in the required format.

+4
source

If you set django_celery , you can request views, such as task_status or is_task_successful , which are part of the djcelery.views package. They return a JSON dictionary, so you can process them using JavaScript.

+8
source

Source: https://habr.com/ru/post/1337703/


All Articles