MATLAB engine in Python hangs when interacting with a Simulink model.
Show older comments
I'm currently using the MATLAB engine in Python, usually without any problems. However, I'm running into some issues with the program hanging.
Specifically, currently the deadlock is observed when I call this method:
self.eng.eval("val = get_param(fullPath, parameter)")
where 'eng' is a reference to the MATLAB engine, 'fullPath' is the path to a Scope element in my model and 'parameter' = "TimeSpan".
The engine hangs on this call (although I have done many calls to the same function before this one, successfully) for some reason. Sometimes, it does 'go through' as expected. Interestingly, it always appears to be on this specific object, with this specific parameter, if it hangs. As I said, I query many of my objects with different parameters before this call, but even in a test model with only a Scope element, the deadlock often occurs.
However this does not, seem to occur whenever I run it the *first* time after a reboot of my machine.
When I call the exact same function from within MATLAB, it works fine. Interestingly, when I start a new Python process, and then load the model that my script hangs on, that works fine. I get no error message, it simply hangs. Note that before loading the model, I can perform the call and I get the error correctly. It is only after loading the model with load_system that the call hangs.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!