how to flush child_stdin

joelcarrier at gmail.com joelcarrier at gmail.com
Thu Feb 21 15:34:28 EST 2008


I'm opening up a subprocess like this where slave.py is a text based
app that receives commands and responds with output:

r, w, e = popen2.popen3('python slave.py')

I need to send slave.py a command and see the output,
so I'll do something like:

w.write("command here")
then i'll try this:
w.flush()

A separate thread is reading from r to retrieve output of slave.py.

The problem is that slave.py doesn't seem to receive commands unless I
also do:
w.close()

But I don't want to do this because I'll want to send more commands.

Any idea what is going on?



More information about the Python-list mailing list