Async mo.lazy
hi. Can I use marimo.lazy on async callables (Coroutines) ? Currently, it seems it only works for sync code
5 Replies
Yea I don’t think it’s possible today. But you could maybe create a sync wrapper with asyncio.run()
We can also look into supporting this - shouldn’t be much effort
I tried with asyncio.run, but I get an error: "This cell raised an exception: RuntimeError('asyncio.run() cannot be called from a running event loop')" def sync_code():
asyncio.run(async_calculate())
sync_code()
Ah might be the something like asyncio.get_running_loop
(Sorry on my phone)
no worries, I've tried def sync_code():
loop = asyncio.get_event_loop() loop.run_until_complete(calculate())
sync_code(), but then I get This cell raised an exception: RuntimeError('This event loop is already running')
loop = asyncio.get_event_loop() loop.run_until_complete(calculate())
sync_code(), but then I get This cell raised an exception: RuntimeError('This event loop is already running')
hmm yea maybe we don't support nested event loops. something we can look into.
in the meantime, ill make mo.lazy support async