Open this example in the interactive library
Source code
import asyncio
async def main():
event = asyncio.Event()
async def worker():
await event.wait()
return 'started'
task = asyncio.create_task(worker())
event.set()
return await task
print(asyncio.run(main()))Sample output
started
