Reputation: 21
Since one of my tasks in views.py is time-consuming, so I think I'd better put it in the background. But also, I want to make sure when this task finished, I'll receive something in the front end. How can I achieve this? I've searched and found django-channels, but still, I can't combine the two goals together. Hope someone will help me.
Upvotes: 2
Views: 2034
Reputation: 15233
Always run background tasks using Asynchronous task processing like
For pushing notification use
if you think websockets are difficult for you to maintain go for polling.
Upvotes: 1
Reputation: 9533
You basically have 2 options:
Either you have your client request the status of your long-running task regularly and respond accordingly when it is done.
Or you use sockets between your client and server and inform your client via the socket, when the task is finished. One of the recommend options for sockets is django-channels. Is there anything wrong with it?
Upvotes: 2