how to communicate in python with an external process


Danny Shevitz


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.



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question