In Python, how can I asynchronously await a FutureResult (returned from matlab.engine.start_matlab with background=True)?
이전 댓글 표시
In Python, I would like to be able to do something like this, within an async coroutine:
future_result = matlab.engine.start_matlab(background=True)
await future_result.wait()
As far as I can tell, the future_result.result() method will block until the result is ready, so that will not suffice. I could implement the async await with extra code like
await asyncio.get_running_loop().run_in_executor(
None, lambda: matlab.engine.start_matlab(background=True)
)
but it would be nice to have it built-in.
댓글 수: 2
Manikanta Aditya
2024년 3월 22일
You can use the asyncio library’s wrap_future function to convert a concurrent.futures. Future object into an asyncio.Future object. This allows you to use the await keyword with it.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!