Launching a subprocess without waiting around for the result?
erikwickstrom at gmail.com
Fri Sep 19 01:23:46 CEST 2008
On Sep 18, 3:33 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
> erikcw <erikwickst... at gmail.com> writes:
> > I have a cgi script where users are uploading large files for
> > processing. I want to launch a subprocess to process the file so the
> > user doesn't have to wait for the page to load.
> For "how do I deal with subprocesses from Python", the (new in Python
> 2.4) 'subprocess' module is the default go-to answer
> <URL:http://www.python.org/doc/lib/module-subprocess>, replacing a
> rather fragmented set of modules before it.
> > What is the correct way to launch subprocess without waiting for the
> > result to return?
> Creating an instance of 'subprocess.Popen' will launch the process and
> return the Popen instance. You then have the option of polling it or
> waiting for it to complete.
> \ “To stay young requires unceasing cultivation of the ability to |
> `\ unlearn old falsehoods.” —Robert Anson Heinlein |
> _o__) |
> Ben Finney
So if I create a Popen object and then just ignore the object and exit
the program the subproccess will finish it's work and then exit itself
More information about the Python-list