根据asyncio
制作了asynciox
,并提供sleep方法,尽量不修改源代码的结构,asynciox
支持本地运行和调试
python main.py
from asynciox.base_eventx import BaseEventLoop
from asynciox.taskx import gather, sleep
async def req1(loop):
await sleep(1, loop=loop)
return 1
async def req2():
return 2
async def main(loop):
res = await gather(req1(loop), req2(), loop=loop)
print(res)
if __name__ == '__main__':
loop = BaseEventLoop()
BaseEventLoop().run_until_complete(main(loop))
🎀 🎀 读后有收获可以作者喝咖啡: