In the Python API, how can I redirect the output of an asynchronous function call of a function without return value?

6 ビュー (過去 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()
When running this script, there is only a line feed / carriage return printed. The return value of
is "None".


Bo Li
Bo Li 2017 年 2 月 16 日
What about adding "ret.result()" before printing the output buffer like following?
while not ret.done() : pass
print out.getvalue()
  3 件のコメント
Sven-Eric Krüger
Sven-Eric Krüger 2018 年 5 月 14 日
編集済み: Sven-Eric Krüger 2018 年 5 月 14 日
@Esteban MATLAB itself is always single threaded, but you can asyncronuously call functions. So the Python Script will not hold on the call of the MATLAB Engine, but continue. The MATLAB Interpreter does his stuff on his own and so does the Python Interpreter.


その他の回答 (0 件)


Help Center および File ExchangeCall MATLAB from Python についてさらに検索


Community Treasure Hunt

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

Start Hunting!

Translated by