Occasional infinite while loop in MATLAB engine package for Python when waiting for results

I am using Python 3.7 and compiled the Matlab engine package from Matlab 2020a on an Ubuntu 18.04 OS. I use Matlab package to run some Matlab functions within my Python program, usually everything works fine but sometimes my program gets stuck into an infinite loop waiting for a function to return the values from Matlab engine. Specifically, the program is stuck in the "wait()" function from "BaseFuture" class.
What is the reason for Matlab engine randomly stopping/hanging? Is there a way to solve this random behavior?
UPDATE: I have tried recompiling the package with Matlab 2021b, but I am observing the same behavior...
Following is an excerpt of the Python code from Matlab engine package that results in the infinite waiting loop:
def wait(self, timeout, wait_for_func):
...
time_slice = 1
if timeout is None:
result_ready = self.done()
while not result_ready:
result_ready = wait_for_func(self._future, time_slice)
...

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Call Python from MATLAB 的更多信息

产品

版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by