In views
, I have a process that takes a few seconds to compute. As it stands, this process comes before my view function returns a next webpage. However, it is not crucial that this process runs before, and in fact it can run anytime. Therefore, I am wondering if it is possible to run this process, and then return the next webpage before the process has finished. I suppose this would be considered multi-threading.
For example:
def myViewFunction(request):
myProcess() # This takes a while to finish
return render(request, 'myapp/mywebpage.html')
Can I run myProcess()
in the background, and return render()
as soon as myProcess()
has been called, rather than wait until it has returned?