Starting a long running process on a server from a WSGI application
I need to start a long running process (30 min) via http and get status as it's running. The "process" is basically a Python script that updates a database. I have the following constraints:
Only one instance of the process can run at a time.
The WSGI application is running in several interpreters, so I can't just make a global variable isRunning to k开发者_运维技巧eep track of it.
I need a web page to track the process (status/progress)
No Django, just pure WSGI.
Anyone have any experiences doing the same thing?
Isolate the process as a separate daemon, and use MQ or some other IPC to hand it jobs. Have it update a value in a database as it progresses, and read that value in a web page.
Look at using Celery (http://celeryproject.org/) and run the task outside of the Python web application processes.
精彩评论