📜  新的事件循环 asyncio - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.300000             🧑  作者: Mango

代码示例1
import asyncio

async def foo(loop):
    print('foo')
    loop.stop()

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) # <----
asyncio.ensure_future(foo(loop))
loop.run_forever()