Relative Content

Tag Archive for pythonpython-3.xwebserverpopen

Return output of subprocess.popen() in webserver

I have a Webserver in Python. I want to be able to kick of a long-running asynchronous subprocess and then have the client poll with a GET or POST and receive stdout as well as other information. For each iteration, the server will return the lines of stdout that it has so far. When the process ends, additional information will be returned.
How can I save the instance of cmd=subprocess.popen() so that on subsequent GET/POST, it can make the appropriate calls (e.g. cmd.poll, cmd.stdout.readline(), etc)