I want to make a Python wrapper for another command-line program.
I want to read Python's stdin
as quickly as possible, filter and translate it, and then write it promptly to the child program's stdin
.
At the same time, I want to be reading as quickly as possible from the child program's stdout
and, after a bit of massaging, writing it promptly to Python's stdout
.
The Python subprocess module is full of warnings to use communicate()
to avoid deadlocks. However, communicate()
doesn't give me access to the child program's stdout
until the child has terminated.