Note that there are some explanatory texts on larger screens.

plurals
  1. PO"3-way" Python subprocess pipeline: send stdout and stderr to two different processes?
    primarykey
    data
    text
    <p>Can the "standard" subprocess pipeline technique (e.g. <a href="http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline" rel="nofollow">http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline</a>) be "upgraded" to two pipelines?</p> <pre><code># How about p1 = Popen(["cmd1"], stdout=PIPE, stderr=PIPE) p2 = Popen(["cmd2"], stdin=p1.stdout) p3 = Popen(["cmd3"], stdin=p1.stderr) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. p1.stderr.close() #p2.communicate() # or p3.communicate()? </code></pre> <p>OK, it's actually a different use case, but the closest starting point seems to be the pipeline example. By the way, how does p2.communicate() in a "normal" pipeline drive p1? Here's the normal pipeline for reference:</p> <pre><code># From Python docs output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] </code></pre> <p>I guess I'm ultimately interested in what kind of "process graphs" (or maybe just trees?) can <code>communicate()</code> support, but we'll leave the general case for another day.</p> <p><strong>Update</strong>: Here's the baseline functionality. Without communicate(), create 2 threads reading from p1.stdout and p2.stdout. In the main process, inject input via p1.stdin.write(). The question is whether we can drive a 1-source, 2-sink graph using just communicate()</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload