How to handle lengthy operations?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gilles Ganault

    How to handle lengthy operations?

    Hi

    I have a piece of code that can take a couple of minutes to run,
    causing the browser to time out.

    Is there a way to send empty, fake data to keep the browser happy
    while the code is running on the server?

    Thanks.
  • Schraalhans Keukenmeester

    #2
    Re: How to handle lengthy operations?

    At Thu, 10 May 2007 00:43:26 +0200, Gilles Ganault let his monkeys type:
    Hi
    >
    I have a piece of code that can take a couple of minutes to run,
    causing the browser to time out.
    >
    Is there a way to send empty, fake data to keep the browser happy
    while the code is running on the server?
    >
    Thanks.
    Are you sure it's not the server timing out? max_execution_t ime is a
    setting in php.ini, defaults to 30 secs I believe.

    You could, during processing, use ob_start() and ob_flush() to send some
    stuff to the browser repeatedly.

    Sh.

    Comment

    • Roy Kaldung

      #3
      Re: How to handle lengthy operations?

      Gilles Ganault wrote:
      Hi
      >
      I have a piece of code that can take a couple of minutes to run,
      causing the browser to time out.
      >
      Is there a way to send empty, fake data to keep the browser happy
      while the code is running on the server?
      >
      Thanks.
      Hi Gilles,

      here are two littels hints:





      hth,
      Roy

      Comment

      • nenegoro

        #4
        Re: How to handle lengthy operations?

        On 10 ÍÁÊ, 02:43, Gilles Ganault <nos...@nospam. comwrote:
        Hi
        >
        I have a piece of code that can take a couple of minutes to run,
        causing the browser to time out.
        >
        Is there a way to send empty, fake data to keep the browser happy
        while the code is running on the server?
        >
        Thanks.
        Try to use AJAX. Redirect user to "Please wait..." page which one will
        check if operations are completed and make automatic redirect.

        Comment

        • SterLo

          #5
          Re: How to handle lengthy operations?

          On May 9, 3:43 pm, Gilles Ganault <nos...@nospam. comwrote:
          Hi
          >
          I have a piece of code that can take a couple of minutes to run,
          causing the browser to time out.
          >
          Is there a way to send empty, fake data to keep the browser happy
          while the code is running on the server?
          >
          Thanks.

          What browser are you using and what is the code trying to do?

          Comment

          • Toby A Inkster

            #6
            Re: How to handle lengthy operations?

            Gilles Ganault wrote:
            Is there a way to send empty, fake data to keep the browser happy
            while the code is running on the server?
            Schraalhans Keukenmeester's point is an important one: the browser is not
            the only thing with a timeout -- mod_php has its own timeout too.

            Increase the max execution time as he said. To solve browser timeout
            issues, slowly feed it some dummy data. Assuming that your script is
            outputting HTML or XML, you could include something like this inside one
            of your loops:

            echo "<!-- x -->\n";

            This assumes of course that you don't need to output any HTTP headers as
            part of this long-running code, as body output obviously prevents the
            header() function from working.

            --
            Toby A Inkster BSc (Hons) ARCS
            Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

            Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux

            Comment

            • C.

              #7
              Re: How to handle lengthy operations?

              On 10 May, 20:46, Toby A Inkster <usenet200...@t obyinkster.co.u k>
              wrote:
              Gilles Ganault wrote:
              Is there a way to send empty, fake data to keep the browser happy
              while the code is running on the server?
              >
              Schraalhans Keukenmeester's point is an important one: the browser is not
              the only thing with a timeout -- mod_php has its own timeout too.
              >
              A better solution might be to run asynchronously in a seperate program
              group (running something in the background of a webserver process is
              not a good idea). It's quite easy on Linux/Unix:

              $cmd='/path/to/php/script';

              `at now php $cmd`;

              I've heard that `start php $cmd` will give similar results on MS
              platforms but you'd need to investigate further.

              C.

              Comment

              • Gilles Ganault

                #8
                Re: How to handle lengthy operations?

                On Thu, 10 May 2007 20:46:40 +0100, Toby A Inkster
                <usenet200703@t obyinkster.co.u kwrote:
                >This assumes of course that you don't need to output any HTTP headers as
                >part of this long-running code, as body output obviously prevents the
                >header() function from working.
                Thank everyone for the tips!

                Comment

                Working...