I have a function called from an async function without await, and my function needs to call async functions. I can do this with asyncio.get_running_loop().create_task(sleep()) but the run_until_complete at the top level doesn't run until the new task is complete.
How do I get the event loop to run until the new task is complete?
I can't make my function async because it's not called with await.
I can't change future or sleep. I'm only in control of in_control.
import asyncio
def in_control(sleep):
"""
How do I get this to run until complete?
"""
return asyncio.get_running_loop().create_task(sleep())
async def future():
async def sleep():
await asyncio.sleep(10)
print('ok')
in_control(sleep)
asyncio.get_event_loop().run_until_complete(future())