how to communicate in python with an external process

Danny Shevitz shevitz at lanl.gov
Mon Mar 7 16:58:54 EST 2011


Howdy,

I'm a long time python user but ran across something I have never needed to do
before and don't know how to do it. 

The issue is that I need for my python script to call some matlab routines.
Matlab is very expensive to start running, so I only want to run it once. I also
want the changes I make in one call to matlab persist to the next call to matlab.

I don't know how to do this. What I want to do is something like create a matlab
process, get it's pid and then attach later (this can be in blocking mode) to 
that pid to execute the command, read the output, then go on in my python code
and at some point later, repeat the process of attaching to the persistent
matlab pid...

I am familiar with subprocess.Popen, but I don't understand how to attach to a
pid, as opposed to creating a new matlab instance every time.

Any enlightenment would be appreciated.

thanks,
Danny




More information about the Python-list mailing list