I have the need to kick off a long-running process in response to a form submission in django. Then, I'd like to be able to poll using ajax and have the view respond with the state of the process (started, stopped, or running). Additionally, I want to be able to stop the process.
so my view looks like this:
def start()
. . .
def stop()
. . .
def status()
. . .
This particular question has been addressed multiple times on S.O., but my situation is subtly different: I am looking for a solution that is entirely pythonic, does not require anything not found in stock django, and does not require the use of a database.
The closest thing I have found is this post. I have implemented the code, and streamlined it quite a bit, but it turns out that request.session is not global (two browsers have different sessions).
It might be that my problem could be solved by using something other than request.session to save the start/stop/status state, but I have no idea what that would be.
Another possibility I came across in my reading is django middleware, but according to this,
_init_() is called only once — at server startup — not for individual requests
There is also a blog post here that talks about global state in django. Any thoughts?
TIA, Noah