Shane Hathaway wrote: > > Make sure the pipes are unbuffered. Launch the process with "python -u" > and flush() the streams after writing. (That's the issue I've > encountered when doing this before.)
The -u option is critical, yes. I wrote some code recently which communicated with a subprocess where the input/output exchanges aren't known in advance, and my technique involved using socket.poll and one character reads from the subprocess. I note that Pexpect is also conservative about communicating with subprocesses (see the "$ regex pattern is useless" section on the Pexpect site [1]). Generally, any work with asynchronous communications, or even socket/pipe programming in a wider sense, seems to involve ending up with working code that looks a lot like the code you started out with, but only after a period of intense frustration and with a few minor adjustments being made to separate the two. Paul [1] http://pexpect.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list