popen4 hanging on write

rinkworks sam at rinkworks.com
Fri Sep 17 18:21:28 EDT 2004


I'm having trouble with Popen4 locking up on me.  It appears to be
unrelated to the actual command I'm running, because I made the command
just "cat" (I'm on UNIX) to echo whatever input I sent it, and it's still
locking.  The trick is, it works for small amounts of data.  After roughly
1.5K of input, it locks up and will not write any more data to the pipe. 
I assume a buffer got full somewhere, and it's blocking the write call.

Meanwhile, I can't read the output, because if I do that, that blocks,
too.

Anybody know how to resolve this problem?  Here is my current code:

        import popen2
        pipe = popen2.Popen4("cat")
        pipe.tochild.write(data)
        pipe.tochild.close()
        output = pipe.fromchild.read()
        print output

Again, when data is just a few lines, it works, but not if it's maybe 1500
bytes or more.  No documentation I can find addresses this problem; the
above is theoretically supposed to just work.  I don't get it.

Thanks for any help anyone can give me.




More information about the Python-list mailing list