Unbuffered read from process using subprocess in Python
<p>I am trying to read from a process that produces long and time-consuming output. However, I want to catch it's output <em>as and when</em> it is produced. But using something like the following seems to be buffering the command's output, so I end up getting the output lines all at once:</p>

<pre><code>p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, bufsize=0)
    for line in p.stdout:
        print line
</code></pre>

<p>I am trying this on MacOS 10.5</p>
