(embedding) running Python as coprocess

William Park opengeometry at yahoo.ca
Wed Feb 19 16:40:09 EST 2003


I've managed to fully embed Python into Bash.  But, the result is 1.4Meg
in size.  I'm wondering if there is better and more general way of
running Python as coprocess in the background.

That is, with Python running in the background, I want to send one batch
of commands to Python and read the result back, send another batch and
read the result, and so on.  Python should not terminate between
batches, because I want to access data from previous calls.

I've tried something like
    python <fifo.in >fifo.out &
    echo "print 2.0+3.0" > fifo.in
    cat fifo.out
I get the result, but Python terminates as soon as EOF is reached in the
<stdin> stream.

My embedded Python will stay alive between batches.  But, this solves
problem only for Python.  Any insight to solving this problem for a any
external program (ie. Perl, Ruby, etc.) would be greatly appreciated.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data management and processing. 




More information about the Python-list mailing list