[Baypiggies] Subprocess: Common problem/common pattern

Keith Dart keith at dartworks.biz
Mon Oct 4 02:00:57 CEST 2010


=== On Sat, 10/02, Brian Palmer wrote: ===
> You have to consider buffering on both the input and output sides of
> a pipe. By default, your C library is probably buffering stdout in a
> pipeline to some large blocksize.
===

In these cases it's the kernel that is buffering the pipe. On Linux
that seems to be about 4K. If the parent process does not read it's end
the buffer will fill up and the subprocess with block on I/O. The
parent process can either do a blocking read on the its side of the
pipe or pty (master side), or use select/poll/epoll to check for
available input. 

This kind of I/O bound stuff is what twisted is good at. I would
suggest you learn that, and look at twisted-runner. 

An alternative is pexpect. But I use pycopia.expect :-)




-- Keith Dart

-- 
-- ------------------------------
Keith Dart
=================================



More information about the Baypiggies mailing list