In the Python API, how can I redirect the output of an asynchronous function call of a function without return value?
7 次查看(过去 30 天)
显示 更早的评论
I am using the Python API and I want to redirect the output of an asynchronously called function without return value. Is this maybe impossible?
My Python Script looks a little bit like this:
import matlab.engine as eng
import StringIO
out = StringIO.StringIO()
MAT = eng.start_matlab()
ret = MAT.func('arg', async=True, nargout=0, stdout=out)
while not ret.done() : pass
print out.getvalue()
MAT.quit()
When running this script, there is only a line feed / carriage return printed. The return value of
ret.result()
is "None".
0 个评论
采纳的回答
Bo Li
2017-2-16
What about adding "ret.result()" before printing the output buffer like following?
while not ret.done() : pass
ret.result()
print out.getvalue()
3 个评论
Esteban Henriques
2018-5-11
编辑:Esteban Henriques
2018-5-11
From:
def result(self, timeout=None):
in fevalfuture.py, it seems that it is not possible to get any feedback from the out stream until the call is done. Doesn't this at least in part defeat the purpose of an async call?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from Python 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!