title: Realtime output from subprocess in Python
body: <p>I am running a Django webserver, and am trying to print the output of a subprocess in real-time to the log. If I commend out the readline line and uncomment the yowzer line, I get the desired stream of logged output, but as soon as I try to run this as-is I get no output. What am I doing wrong? All the results I can find seem to suggest that this would work as-is.</p>
  
  <pre><code>sp = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
  
  while sp.poll() is None:
      logging.critical(sp.stdout.readline())
      #logging.critical('yowzer')
      time.sleep(10)
  </code></pre>
  
  <p>Thank you!</p>
  
  <p><strong>[edit April 3]</strong> It turns out the issue wasn't that the command was long-running, but rather that I was using a semicolon to concat a 'su user' command with the main command. Removing the su solved the issue.</p>