FAQ
Hi, All:
I have written a python CGI script to run in html web page. When I access to
the html page, it only runs part of the script, then abort because the late part of
the script is involved in database access, it is slow. I wonder whether there is
a way to control html running speed so that it can wait for CGI script to complete
execution, then write the results to html page ?
Thanks a lot .

Yong

Search Discussions

  • Christoph Haas at Aug 17, 2006 at 8:06 pm

    On Thursday 17 August 2006 21:50, Yong Wang wrote:
    I have written a python CGI script to run in html web page. When I
    access to the html page, it only runs part of the script, then abort
    because the late part of the script is involved in database access, it
    is slow. I wonder whether there is a way to control html running speed
    so that it can wait for CGI script to complete execution, then write the
    results to html page ?
    You could use

    output = ''
    output += 'Something else to print'

    instead of

    print 'Something else to print'

    And finally use

    print output

    Or to use that more efficiently use a list of strings and append to that
    list. That's probably faster than creating another immutable string time
    and again. And finally you just ' '.join(outputlist) and print that.

    Cheers
    Christoph
  • Tim at Aug 17, 2006 at 8:24 pm

    Yong Wang wrote:
    Hi, All:
    I have written a python CGI script to run in html web page. When I access to
    the html page, it only runs part of the script, then abort because the late part of
    the script is involved in database access, it is slow. I wonder whether there is
    a way to control html running speed so that it can wait for CGI script to complete
    execution, then write the results to html page ?
    Thanks a lot .

    Yong
    Yong,

    Are you reffering to your browser connection to web server timing out
    waiting for query to complete?

    I had some long running scripts that would do that so I used a timer
    thread to print comments to the browser IE: <!-- keep alive -->. Brute
    force approach but it worked using IE with apache. If I remember right
    you have to call sys.stdout.flush() to force the write over socket to
    happen right away.

    Tim
  • Steve Holden at Aug 17, 2006 at 8:34 pm

    Yong Wang wrote:
    Hi, All:
    I have written a python CGI script to run in html web page. When I access to
    the html page, it only runs part of the script, then abort because the late part of
    the script is involved in database access, it is slow. I wonder whether there is
    a way to control html running speed so that it can wait for CGI script to complete
    execution, then write the results to html page ?
    Thanks a lot .

    Yong
    Most servers impose some sort of CPU limit on CGI processes (though
    typically this defaults to a value of 30 seconds or more). If you really
    are going past your server's default(?) limit you really need to either
    tweak the limit up on the server (at least for that script) or
    reconsider whether the application is suitable for CGI in the first place.

    What kind of "slow" are we talking about here? A minute? Ten minutes?

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden
  • Steve Holden at Aug 17, 2006 at 8:55 pm

    Yong Wang wrote:
    Hi Steve:
    The propblem I run into is about one minute. The CGI script is not completed to run and aborted.
    If I run the python script in backend solaris machine, the script needs about one minute for database
    access.
    Thanks,

    Yong
    In which case you probably need to tweak the server timeout setting.
    Nothing you can do from Python (except possibly make your CGI run faster).

    regards
    Steve
    Yong Wang wrote:
    Hi, All:
    I have written a python CGI script to run in html web page. When I access to
    the html page, it only runs part of the script, then abort because the late part of
    the script is involved in database access, it is slow. I wonder whether there is
    a way to control html running speed so that it can wait for CGI script to complete
    execution, then write the results to html page ?
    Thanks a lot .

    Yong
    Most servers impose some sort of CPU limit on CGI processes (though
    typically this defaults to a value of 30 seconds or more). If you really
    are going past your server's default(?) limit you really need to either
    tweak the limit up on the server (at least for that script) or
    reconsider whether the application is suitable for CGI in the first place.

    What kind of "slow" are we talking about here? A minute? Ten minutes?

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden

    --
    http://mail.python.org/mailman/listinfo/python-list



    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden
  • Tim Chase at Aug 17, 2006 at 9:04 pm

    In which case you probably need to tweak the server timeout
    setting. Nothing you can do from Python (except possibly make
    your CGI run faster).
    Or have Python send a better SQL statement that would run
    faster...a little SQL mojo goes a long way.

    The OP failed (as far as my thread-dabbling has noticed) to
    specify what sort of SQL is being run. If full table results are
    being returned just to be discarded, or there are more efficient
    ways of doing things in the SQL, one would be better off doing it
    on the server and letting it return a single finely-honed
    result-set. With some insight into the SQL statement(s), one
    might be able to find glaring bottlenecks.

    -tkc

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 17, '06 at 7:50p
activeAug 17, '06 at 9:04p
posts6
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase