How do clients(web browser) close a python CGI program that is not responding?

Jon Ribbens jon+usenet at unequivocal.co.uk
Tue Mar 28 04:36:38 EST 2006


In article <1143521853.097142.57740 at z34g2000cwc.googlegroups.com>, Sullivan WxPyQtKinter wrote:
> Hi,there. Sometimes a python CGI script tries to output great
> quantities of HTML responce or in other cases, it just falls into a
> dead loop. How could my client close that CGI script running on the
> server? I tried to use the STOP button in the web browser button, but
> it does not work.

It depends on what CGI framework you're using. If the user hits
'stop', the client browser should close its connection and your web
server should close the pipe to your CGI process. I'd expect you to
get a SIGPIPE when next trying to output data.

> In addition, how could I configure that if a CGI program do not finish
> its task in 20sec or so, it will be automatically terminated?

Do you mean a specific CGI, or all CGIs in general? If it's in general
then you need to see if your web server can be configured to do that.
If it's a specific CGI, check out signal.alarm() or
resource.setrlimit(resource.RLIMIT_CPU, ...). Apache has a RLimitCPU
directive, but be careful with it since it may well not do what you
expect.



More information about the Python-list mailing list