Python 2.2.1 and select()

Noah noah at noah.org
Mon Mar 24 20:52:54 EDT 2008


On Mar 24, 2:58 pm, Derek Martin <c... at pizzashack.org> wrote:
> If and only if the total amount of output is greater than the
> specified buffer size, then reading on this file hangs indefinitely.
> For what it's worth, the program whose output I need to capture with
> this generates about 17k of output to STDERR, and about 1k of output
> to STDOUT, at essentially random intervals.  But I also ran it with a
> test shell script that generates roughly the same amount of output to
> each file object, alternating between STDOUT and STDERR, with the same
> results.
>

I think this is more of a limitation with the underlying clib.
Subprocess buffering defaults to block buffering instead of
line buffering. You can't change this unless you can recompile
the application you are trying to run in a subprocess or
unless you run your subprocess in a pseudotty (pty).

Pexpect takes care of this problem. See http://www.noah.org/wiki/Pexpect
for more info.

--
Noah



More information about the Python-list mailing list