I want to call OpenModelica from asynchronous code using trio, but cannot do so.
import trio
from omc4py import open_session
async def main() -> None:
with open_session(asyncio=True) as session:
await session.getVersion()
if __name__ == "__main__":
trio.run(main)
$ python trio_omc.py
/home/ijknabla/sandbox/python/.venv/lib/python3.12/site-packages/zmq/_future.py:708: RuntimeWarning: No running event loop. zmq.asyncio should be used from within an asyncio loop.
self._update_handler(self._state)
Traceback (most recent call last):
File "/home/ijknabla/sandbox/python/trio_omc.py", line 12, in <module>
trio.run(main)
File "/home/ijknabla/sandbox/python/.venv/lib/python3.12/site-packages/trio/_core/_run.py", line 2288, in run
raise runner.main_task_outcome.error
File "/home/ijknabla/sandbox/python/trio_omc.py", line 8, in main
await session.getVersion()
File "/home/ijknabla/sandbox/python/.venv/lib/python3.12/site-packages/omc4py/algorithm.py", line 20, in _fmap
return f(await a)
^^^^^^^
File "/home/ijknabla/sandbox/python/.venv/lib/python3.12/site-packages/omc4py/interactive.py", line 119, in __asynchronous_evaluate
result = await socket.recv_string()
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: trio.run received unrecognized yield message <Future pending cb=[_AsyncSocket._deserialize.<locals>._chain_cancel() at /home/ijknabla/sandbox/python/.venv/lib/python3.12/site-packages/zmq/_future.py:382]>. Are you trying to use a library written for some other framework like asyncio? That won't work without some kind of compatibility shim.
I want to call OpenModelica from asynchronous code using trio, but cannot do so.