我想要实现的是:
tasks = [call(url) for url in urls]

call是Python3.5中的async方法/ coroutine来执行GET请求,比方说aiohttp

因此,基本上所有呼叫都是异步的。现在,我可以运行asyncio.wait(tasks),以后可以一一访问期货中的结果。

但是,我想要的是,假设只有2个网址,然后:
a, b = call(url1), call(url2)

类似于您在Koa中通过产生数组的方式进行操作。任何帮助如何做到这一点,如果可以做到?

最佳答案

var1, var2 = loop.run_until_complete(asyncio.gather(task1, task2))

根据文档,gather保留了传递顺序的顺序

07-27 19:51