[Python-Dev] subprocess crossplatformness and async communication

Hrvoje Niksic hrvoje.niksic at avl.com
Mon Jan 26 14:10:04 CET 2009

Nick Craig-Wood wrote:
> But for the conversational case (eg using it to do a remote login) it
> doesn't work at all :-
>   run child
>   send stuff to stdin
>   child reads stdin and writes stdout

Can this really be made safe without an explicit flow control protocol, 
such as a pseudo-TTY?  stdio reads data from pipes such as stdin in 4K 
or so chunks.  I can easily imagine the child blocking while it waits 
for its stdin buffer to fill, while the parent in turn blocks waiting 
for the child's output arrive.

Shell pipelines (and the subprocess module as it stands) don't have this 
problem because they're unidirectional: you read input from one process 
and write output to another, but you typically don't feed data back to 
the process you've read it from.

More information about the Python-Dev mailing list