arokem / python-matlab-bridge

A simple Python => MATLAB(R) interface and a matlab_magic for ipython
BSD 2-Clause "Simplified" License
332 stars 97 forks source link

Increase timeout for starting matlab with magic commands #223

Open yuvval opened 8 years ago

yuvval commented 8 years ago

Hi,

The Matlab on my machine takes more than 60 seconds to start.

If I do the following, it retries to connect twice to the same socket, and is successful on the 2nd attempt:

try:
    mlab.start()
except:
    mlab.start()

Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-877c65da-8d47-44b8-9eec-848d2682a405
Send 'exit' command to kill the server
............................................................MATLAB session timed out after 60 seconds
Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-877c65da-8d47-44b8-9eec-848d2682a405
Send 'exit' command to kill the server
.MATLAB started and connected!

However when I try the same with magic commands, it tries a different socket every time. So my connection is unsuccessful

try:
    %load_ext pymatbridge
except:
    %load_ext pymatbridge

Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-39a22f49-829e-48fe-baa3-407543d366c3
Send 'exit' command to kill the server
............................................................MATLAB session timed out after 60 seconds
Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-a8f8cf0b-6077-4524-87c7-469cceec5676
Send 'exit' command to kill the server
............................................................MATLAB session timed out after 60 seconds

Any idea on how to overcome this issue?

Thanks for your assistance!

Yuval

BTW: wrt the previous issue I reported, I am now running from an ubuntu machine instead of a RHEL (still no su permissions though).

arokem commented 8 years ago

Glad to hear you have this working (with apologies again for not supporting RHEL - if any users out there want to help build the messenger on that platform - that would be excellent!).

Concerning your issue - note that you can use the 'maxtime' key-word argument to longer intervals than 60 seconds. For example:

mlab = pymatbridge.Matlab(maxtime=120)

To start the ipython extension, you should probably use the syntax used in this example:

https://github.com/arokem/python-matlab-bridge/blob/master/pymatbridge/examples/matlab_magic.ipynb

Loading the extension with:

pymat.load_ipython_extension(ip, maxtime=120)
arokem commented 8 years ago

You can also pass socket_addr to specify the address to use

yuvval commented 8 years ago

Thanks again,

Unfortunately increasing the timeout (even to 10 minutes) didn't solve the issue. Could you please explain how to use the socket_addr with the extension? (I tried with no luck - but not sure i got the syntax right)

Many (Many) Thanks :)

arokem commented 8 years ago

You are correct - it is not currently possible to pass the socket address. I think that #224 should fix that, once merged. I'll let others take a look if they want and merge it some time next week, but you can try out that code for the time being.