In my Python application, I have a sync function boo()
that is called inside a running event loop. boo()
has to get some data from foo(arg1, arg2)
, which is an async function.
Unfortunately, I can’t turn boo()
into an async function. It must stay synchronized. (This constraint is out of my hands).
How can I call foo(arg1, arg2)
from within boo()
, wait until it completes, and continue the execution?
I tried to do
loop = asyncio.get_event_loop()
data = loop.run_until_complete(foo(arg1, arg2))
I also tried
data = asyncio.run_in_executor(None, foo, arg1, arg2)
None of this worked.