24 ms·
I'm not sure, but it seems an overly complex approach. If all you want is to execute an async function from a sync context, run and wait for it: >>> import
by BerislavLopac 8y ago
I'm not sure, but it seems an overly complex approach. If all you want is to execute an async function from a sync context, run and wait for it:
>>> import asyncio
>>> async def foo():
... return 'foo'
...
>>> bar = asyncio.run(asyncio.wait_for(foo(), timeout=15))
>>> print(bar)
foo
>>>