python create_future

 

 

import asyncio

async def main():
    loop = asyncio.get_running_loop()
    future = loop.create_future()
    print("Future created:", future)
    await asyncio.sleep(1)
    future.set_result("Hello, World!")
    print("Result:", await future)

asyncio.run(main())

 

posted @ 2023-10-16 15:35  AngDH  阅读(9)  评论(0编辑  收藏  举报