Long cgi page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Faulkner

    Long cgi page

    I am writing a simple cgi app and I would like it to print the header
    of an html page and "Running... " then print the results (which take
    over a minute to calculate)

    But...

    None of the page displays until the program finishes.

    Is there any way of flushing the first half of the page out before the
    calculation starts?

    Simon
  • Jegenye 2001 Bt

    #2
    Re: Long cgi page

    sys.stdout.flus h()
    See Python ref.

    Best,
    Miklós

    Simon Faulkner <news@titanic.c o.uk> wrote in message
    news:nfolovgho3 ih3l7jcef7bvq0b fjs2d6es1@4ax.c om...[color=blue]
    > I am writing a simple cgi app and I would like it to print the header
    > of an html page and "Running... " then print the results (which take
    > over a minute to calculate)
    >
    > But...
    >
    > None of the page displays until the program finishes.
    >
    > Is there any way of flushing the first half of the page out before the
    > calculation starts?
    >
    > Simon[/color]


    Comment

    • bromden

      #3
      Re: Long cgi page

      > None of the page displays until the program finishes.

      it's because the http server "waits" till the cgi program finishes,
      flushing stdout will not work

      --
      bromden[at]gazeta.pl

      Comment

      • A.M. Kuchling

        #4
        Re: Long cgi page

        On Mon, 13 Oct 2003 18:35:44 +0100,
        Simon Faulkner <news@titanic.c o.uk> wrote:[color=blue]
        > Is there any way of flushing the first half of the page out before the
        > calculation starts?[/color]

        You're better off using a redirect. On the inital request, run the
        calculation in a subprocess or a subthread and return a brief page that says
        "Please wait...". This page should contain a <META HTTP-EQUIV="Refresh" >
        element that will reload the page in some suitable time span. On reloading,
        the application should check if the computation is done and either return
        the results or another "Please wait" page.

        Quixote pseudocode:

        def calc [html] (request):
        if not request.session .computation_in _progress():
        # Fork off subprocess
        elif request.session .computation_co mpleted():
        "Results:"
        ...
        else:
        # Computation is in process
        "<html><hea d>"
        '<meta http-equiv="refresh" content="10; %s">' % request.get_url ()
        '</head><body> ... </body></html>'

        You'd have to write the computation_com pleted() and computation_in_ progress()
        methods.

        --amk

        Comment

        • Dave Benjamin

          #5
          Re: Long cgi page

          In article <3tGdnV9ZFdhZ0B aiRTvUpA@speake asy.net>, A.M. Kuchling wrote:[color=blue]
          > On Mon, 13 Oct 2003 18:35:44 +0100,
          > Simon Faulkner <news@titanic.c o.uk> wrote:[color=green]
          >> Is there any way of flushing the first half of the page out before the
          >> calculation starts?[/color]
          >
          > You're better off using a redirect. On the inital request, run the
          > calculation in a subprocess or a subthread and return a brief page that says
          > "Please wait...". This page should contain a <META HTTP-EQUIV="Refresh" >
          > element that will reload the page in some suitable time span. On reloading,
          > the application should check if the computation is done and either return
          > the results or another "Please wait" page.[/color]

          I don't know how to translate this to Quixote, but another way to do this
          would be to use an HTTP refresh header, which has the additional advantage
          that it's not strictly limited to HTML.

          Just a thought,
          Dave

          --
          ..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
          : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :

          Comment

          Working...