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

Discussion in 'Python' started by Sullivan WxPyQtKinter, Mar 28, 2006.

  1. 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.

    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?
    Sullivan WxPyQtKinter, Mar 28, 2006
    #1
    1. Advertising

  2. Sullivan WxPyQtKinter

    Ben Sizer Guest

    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?


    Generally speaking, remote users don't have control over your local
    processes, and if there is some problem with that local process that
    causes it to loop indefinitely, the chance that it could react
    appropriately to the browser is slim anyway. So the answer is to fix
    the problem with the CGI program.

    > 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?


    I suppose you could run it in a background thread or process,
    terminating it after the allotted time has expired, but I suspect you'd
    be better off addressing whatever is causing the problem in the first
    place. What sort of CGI program is this?

    --
    Ben Sizer
    Ben Sizer, Mar 28, 2006
    #2
    1. Advertising

  3. Sullivan WxPyQtKinter

    Jon Ribbens Guest

    In article <>, 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.
    Jon Ribbens, Mar 28, 2006
    #3
  4. Actually my project is converting certain specially costomized XML
    file to HTML to display and edit. Sometimes the XML file is too big, or
    the client upload a very huge file for the server to process, which
    exceeds the processing ability of my server.(after all, it is a small
    server on my poor laptop....which use winXP and IIS......not
    professional, huh?)

    I configures IIS to terminate CGI program if it do not complete in 20
    sec. But it does not work....Perhaps I should go to a IIS or apache
    forum for answer.

    Thank you.
    Sullivan WxPyQtKinter, Mar 28, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denon
    Replies:
    1
    Views:
    571
    Saravana [MVP]
    Nov 14, 2003
  2. Sullivan WxPyQtKinter

    To my clients force to terminate a python CGI program?

    Sullivan WxPyQtKinter, Mar 28, 2006, in forum: Python
    Replies:
    0
    Views:
    311
    Sullivan WxPyQtKinter
    Mar 28, 2006
  3. Francesco
    Replies:
    1
    Views:
    526
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Dec 27, 2006
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    839
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Replies:
    0
    Views:
    490
Loading...

Share This Page