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.
If you have django_celery installed, you can query views like task_status
or is_task_successful
that come in the djcelery.views
package. They return a JSON dictionary so you can handle them with JavaScript.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With