arokem/python-matlab-bridge

How to exit gracefully Matlab on exception (SIGINT)

Opened this issue · 0 comments

I am writing a script that run Matlab from pymatbridge. When I stop the script with SIGINT (Ctrl-C), the Matlab instance fails to close. How can I close it?
This is my code:

class Schedule(object):
    exposed = True

    def __init__(self):
        # FIXME
        self.mlab_path = "/Applications/MATLAB_R2015a.app/bin/matlab"
        self.mlab = Matlab(executable=self.mlab_path)
        self.mlab.start()

    def __enter__(self):
        pass

    def __exit__(self, exc_type, exc_value, traceback):
        self.mlab.stop()