cgi long running jobs

Thomas Guettler guettli at
Mon Oct 4 16:38:44 CEST 2004

Am Sun, 03 Oct 2004 07:01:50 -0700 schrieb Vineeth S:

> Hi,
> I have a web app set up, it is one long job and goes on for about 20
> or 30 seconds. When the request comes in, I throw a "please wait", set
> the job on its way, and want to periodically update the "please wait"
> thrown.
> What I tried initially was a client-pull, where with the first "please
> wait" I would send a refresh header with a flag as parameter, and then
> use that flag to check for completion, else send a new "please wait
> <blah>". This did not work, I am guessing, because the request and the
> subsequent process has been tied to that session, am I correct ?


How do you check the flag?

You can do it like this:
One script or method called "startProcess": Start the
real work in background (os.system(".... 2>&1 &")).
This returns a redirect to "waitForProcess?id=..."

The second scripts redirects itself to the same URL
after 1 second (in the head tag of the html), if
the process has not completed. Otherwise return the result.
You can add some progress meter which gets updated
every second.

> Going by that reasoning, I tried a fork-exec to run the long job, and
> periodically check for completion from the parent. This does not work
> either, and this has foxed me. Is it because fork-exec in the cgi
> context has some other behaviour ?

What kind of session-management do you use?


More information about the Python-list mailing list