cgi long running jobs

Michael Foord fuzzyman at gmail.com
Tue Oct 12 16:46:47 CEST 2004


vineeth at gmail.com (Vineeth S) wrote in message news:<383854e0.0410120153.2fcc5424 at posting.google.com>...
> Thomas Guettler <guettli at thomas-guettler.de> wrote in message news:<pan.2004.10.04.14.38.43.605384 at thomas-guettler.de>...
> > Am Sun, 03 Oct 2004 07:01:50 -0700 schrieb Vineeth S:
> > 
>  
> > > 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 ?
> > 
> > Hi,
> > 
> > How do you check the flag?
> > 
> 
> I check to see if the form has this variable
> 
> > 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=..."
> > 
> 
> Ah, I didnt think of backgrounding the job. But I am wondering will
> apache release control to another script or page ? In the sequential
> nature of things it should. I will try this.

I don't *know* but many servers are set up not to allow background
processes and not to allow any CGI process to run for more than a set
length of time. On servers this is 1 minute, on others it can even be
30 seconds.

Can you split your process into several parts ? You an then send a
redirect header causing the browser to send a new request which
triggers the next part - effectively chaining requests through
redirect headers.

> > 
> > > 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?
> > 
> 
> I did not understand what exactly you meant by session-management.
> 

How do you save the state of each process in between accesses.
The answer is probably that you aren't doing any. If you follow my
suggestion you will have to 'save the state' of your process part way
through for it to pick up in the next request. You will then have to
work out some way of dealing with saved stuff that never gets
completed - this is all 'session management'.

Regards,


Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html


> > HTH,
> >  Thomas
> 
> Thanks and regards
> Vineeth



More information about the Python-list mailing list