Bi-directional communication with external programs?

Donn Cave donn at u.washington.edu
Tue Jun 3 14:12:54 EDT 2003


Quoth Norbert Nemec <nobbi_at_theorie3.physik.uni-erlangen.de at NOSPAM.COM>:

| can anybody help me on this: I want to communicate bidirectionally with a
| gnuplot session I spawned from python.
|
| I.e.
| * popen3 for input/output/stderr
| * write one command
| * read and evaluate result
| * write next command
| * read and evaluate result
| etc.
|
| Problem: file.readline does block if there is nothing to read and select()
| does not seem to do anything useful either (it always tells me that there
| is data to read, even though there is none.)
|
| Unfortunately, I cannot predict in advance how much to read, as
| errormessages and other data comes through the same pipe and have to be
| discarded somehow.
|
| Anybody out there who can help me on that?

Maybe, but if it were so simple, there would be a more neatly packaged
solution and you would be using it already.  Since you have a lot of
rather general issues, maybe more than you realize, and no specific
code, maybe it would be worth your time to search Google's comp.lang.python
archive for information about popen, popen3, pipes etc.  Bidirectional
I/O is harder than one would think.  Pay attention to anything you read
about buffered I/O.

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list