<br><div class="gmail_quote">On Sat, May 28, 2011 at 4:32 PM, Tim Roberts <span dir="ltr"><<a href="mailto:timr@probo.com">timr@probo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">TheSaint <<a href="mailto:nobody@nowhere.net.no">nobody@nowhere.net.no</a>> wrote:<br>
><br>
>I'm looking into subprocess.Popen docs.<br>
>I've launch the program with its arguments and that's smooth. I'm expecting<br>
>to read the output by *comunicate()* at every line that prgram may blow<br>
>during the process, but the output is given only when the child process is<br>
>ended.<br>
>I'd like to process the lines to display an information in percentage during<br>
>the running time of the child.<br>
<br>
</div>Are you specifying a buffer size in the Popen command? If not, then the<br>
Python side of things is unbuffered. It's possible that the application<br>
you are launching is buffering its output, so that it doesn't SEND until<br>
the application ends.<br></blockquote><div><br>I believe there are 4 normal ways, and 1 special way of getting output from a buffered application:<br><br>1) As you mentioned, the program could terminate<br>2) Also, the program could just have written enough to fill its buffer, so it outputs the content of the buffer before starting to fill it again<br>
3) Also, the program could call flush<br>4) Also, the program could use an unbuffered file, like stderr - not all file in an application are astonishingly likely to be buffered the same way<br><br>And the special one:<br>
1) Sometimes you can take a buffered program and get it to be unbuffered (or at least line buffered) by running it on a pty.<br><br></div></div>