FAQ
Hi there,

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?

Thanks,
Nobbi

Search Discussions

  • Gerhard Häring at Jun 3, 2003 at 12:58 pm

    Norbert Nemec wrote:
    Hi there,

    can anybody help me on this: I want to communicate bidirectionally with a
    gnuplot session I spawned from python. [...]
    Shouldn't http://gnuplot-py.sourceforge.net/ make this unnecessary?

    -- Gerhard
  • Helmut Jarausch at Jun 3, 2003 at 1:55 pm

    Norbert Nemec wrote:
    Hi there,

    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.
    Maybe you want to use ExpectPy http://expectpy.sourceforge.net

    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
  • Donn Cave at Jun 3, 2003 at 6:12 pm
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 3, '03 at 12:50p
activeJun 3, '03 at 6:12p
posts4
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase