Dev HelpersOpen library
← Back

Resolve a Future from the event loop

Resolve a Future from the event loop in Python.

Open this example in the interactive library

Source code

import asyncio
async def main():
    loop = asyncio.get_running_loop()
    future = loop.create_future()
    loop.call_soon(future.set_result, 'ready')
    print(await future)
asyncio.run(main())

Sample output

ready