title: subprocess.Popen : Separating stdout/stderr but keeping order
body: <p>How do I get the output from a command using subprocess.Popen and have separate callbacks for stdout and stderr, but ensure that those callbacks are called in the order that the lines came from the process?</p>
  
  <p>If I didn't care about separating out STDOUT and STDERR then I could do:</p>
  
  <pre><code>fd = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
  line = fd.stdout.readline()
  while line :
      callback( line )
      line = fd.stdout.readline()
  </code></pre>
  
  <p>However, if I have <code>stdoutCallback</code> and <code>stderrCallback</code>, and want them called on the appropriate outputs, but in the same order as the above code would call <code>callback</code> on, how would I go about doing this?</p>