CGI and long running job

merry.sailor at gmail.com merry.sailor at gmail.com
Sat Dec 3 10:48:53 EST 2005


jmdeschamps at gmail.com wrote:
> merry.sailor at gmail.com wrote:
> > Hello,
> > I am using python and CGI to initiate a long running simulation (up to
> > 5h long) on a remote machine. The main idea is that I use a form, enter
> > the parameters and a CGI scripts start the simulation using these
> > parameters. The structure of the script is:
> >
> > 1. Read paremeters
> > 2. Display some information
> > 3. Start the simulation
> >
> > For step 3 I use either os.system or os.popen(2). The problem is that
> > the web server does not send the information of step 2 back to the
> > browser, unless step 3 is completed. The browser simply waits for a
> > response, without displaying anything. How can I just read the params,
> > display the info I want, start the simulation and then terminate either
> > the script or at least the connection to the browser without having to
> > wait for the simulation to finish?
> >
> > I am using activestate python 2.4, Apache and WinXP.
> >
> > Thanks a lot for your help.
>
> Maybe you could use 'os.spawn' variants with the P_NOWAIT parameter...
> (not sure of the syntax here, it's in the doc)
> Good luck!

Thanks for answering. I tried that but it didn't work. Nothing is sent
back to the browser until the spawned process has ended. This is true
even if the spawn command (or any other similar command) is the last
statement of the script.

Is there some way to send back to the browser whatever info I need,
close the connection and then continue executing the commands I need,
using the same script?




More information about the Python-list mailing list