Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Long Process Waits Until End to Display Results

by C_T (Scribe)
on Dec 07, 2004 at 17:33 UTC ( [id://412952]=note: print w/replies, xml ) Need Help??


in reply to Re: Long Process Waits Until End to Display Results
in thread Long Process Waits Until End to Display Results

Someone sent me that excellent article in response to another question. The problem is not the browser timing out, but rather that the process waits until the end to display the results.

I've actually used the exact code that's in the article you reference:

my $command = "make -i -j 10 -f upgrade.make"; unless (open F, "-|") { open STDERR, ">&=1"; exec "$command"; } while (<F>) { $buffer .= $_; $cache->set($session, [0, $buffer]); }

And it still waits until the process completes to give me back any output whereas if I run $command from the command line it gives me real-time feedback.

CT

Charles Thomas
Madison, WI

Replies are listed 'Best First'.
Re^3: Long Process Waits Until End to Display Results
by revdiablo (Prior) on Dec 07, 2004 at 19:14 UTC
    The problem is not the browser timing out, but rather that the process waits until the end to display the results.

    You may have a different problem, but merlyn's article is still a possible solution. Have your lengthy process fork off and write its output to a file, then have the CGI refresh every X seconds, reading that output file, and displaying the results. Perhaps you could even parse the output file and make the results a bit more user friendly (this is just speculation -- the output may already be user friendly).

    You may also find that your lengthy process buffers its output writing to the file, though. In that case, you can investigate some of the solutions sgifford recommended.

      Have your lengthy process fork off and write its output to a file, then have the CGI refresh every X seconds, reading that output file, and displaying the results.

      Currently the lengthy process has its output appended to a cache file which is read by the script every 5 seconds, as outlined in Merlyn's article.

      CT

      Charles Thomas
      Madison, WI

        So the lengthy process is buffering when writing to the output file? If so, it sounds like the program you're executing is doing the buffering, and I quote sgifford:

        If that's the case, finding an option to cause the program to display output immediately is the easiest solution; the other option is to connect it to a pseudo-tty, with something like Expect.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://412952]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found