title: How to capture streaming output in python from subprocess.communicate()
body: <p>Currently, I have something like this:</p>
  
  <pre><code>self.process = subprocess.Popen(self.cmd, stdout=subprocess.PIPE)
  out, err = self.process.communicate()
  </code></pre>
  
  <p>The command I'm running streams the output, and I need the process to block before continuing.</p>
  
  <p>How do I make it so that I can capture the streaming output AND have the streaming output printing through stdout? When I set <code>stdout=subprocess.PIPE</code>, I can capture the output, but it won't print the output. If I leave out <code>stdout=subprocess.PIPE</code>, it prints the output, but <code>communicate()</code> will return <code>None</code>. </p>
  
  <p>Is there a solution that would do what I'm asking for WHILE providing blocking until the process is terminated/completed AND avoid buffer issues and pipe deadlock issues mentioned <a href="http://docs.python.org/2/library/subprocess.html#subprocess.Popen.wait" rel="nofollow">here</a>?</p>
  
  <p>Thanks!</p>