title: Get partial stdout and stderr from Popen that runs indefinitely
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1410849/bypassing-buffering-of-subprocess-output-with-popen-in-c-or-python">Bypassing buffering of subprocess output with popen in C or Python</a>  </p>
  </blockquote>
  
  
  
  <p>I'm building a wrapper around a server cmd line script that should run indefinitely.
  What I need to do is to get the current stout without waiting for the subprocess to finish.</p>
  
  <p>I mean, if I run the following, everything works fine:</p>
  
  <pre><code>ls = Popen(["ls"], stdout=PIPE)
  output = ls.stdout.read()
  </code></pre>
  
  <p>But if I do the same with an indefinitelly running program:</p>
  
  <pre><code>server = Popen(["python","-m","SimpleHTTPServer"], stdout=PIPE)
  output = server.stdout.read()
  </code></pre>
  
  <p>It will not come back...</p>
  
  <p>Update: Even</p>
  
  <pre><code> output = server.stdout.read(1) 
  </code></pre>
  
  <p>hangs...</p>
  
  <p>Do you know if there's a way to capture partial output from a Popen (or similar threading implementation) in an OS independent way?</p>