问题
I'm trying to run a MATLAB script using parfor which runs a simulink model in parallel by sim function, and this simulink model contains a MATLAB Function Block.
The function defined in this block calls a python function using "py." mechanism.
Unfortunately, the run sometimes seems stuck in the middle, when I fed a large number of simulations. The debugging output stops to show up. I suspect a deadlock somewhere.
So, my questions are
- Can we run a simulink model which contains python functions in parallel?
- In what way MATLAB calls the python interpreter? One for each MATLAB worker or One for the entire MATLAB?
I use MATLAB R2017b on Mac.
Addition of March 22, 2018: I contacted to the support and they responded that calling a python function from a MATLAB function block in a simulink model is not supported and anything can happens. Still I'm interested in how MATLAB interacts with (a) python interpreter(s). Is there a single python interpreter which interacts with the whole MATLAB or are there multiple python instances for all MATLAB workers?
Addition of April 22, 2018: Updating MATLAB 2018a seems fix the problem
来源:https://stackoverflow.com/questions/49354940/calling-python-functions-from-matlab-workers