Author vstinner
Recipients gvanrossum, vstinner, yselivanov
Date 2014-03-27.23:22:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> How do you do that with the subprocess module

Something like that:
import subprocess
ls = subprocess.Popen(["ls", "-1"], stdout=subprocess.PIPE)
wc = subprocess.Popen(["wc", "-l"], stdin=ls.stdout)

> and why doesn't that work with asyncio?

It's possible with the two methods of an event loop, but I'm requesting this feature for the high-level API: asyncio.subprocess.

create_subprocess_shell("cat", stdout=subprocess.PIPE) starts immediatly to consume stdout, before I can connect the pipe to "wc" stdin. Currently, the asyncio.subprocess is designed to be able to write:
proc = yield from create_subprocess_exec("ls", stdout=subprocess.PIPE)
stdout, _ = yield from proc.communicate()
Date User Action Args
2014-03-27 23:22:07vstinnersetrecipients: + vstinner, gvanrossum, yselivanov
2014-03-27 23:22:07vstinnersetmessageid: <>
2014-03-27 23:22:07vstinnerlinkissue21080 messages
2014-03-27 23:22:06vstinnercreate