【发布时间】:2019-10-04 21:19:53
【问题描述】:
所以,我有一个任务列表,我想以非阻塞方式同时安排这些任务。
基本上,gather 应该可以解决问题。
喜欢
tasks = [ asyncio.create_task(some_task()) in bleh]
results = await asyncio.gather(*tasks)
但是,我也需要超时。我想要的是任何需要>超时时间的任务都会取消,我会继续我所拥有的。
我犯规了asyncio.wait 原始人。
https://docs.python.org/3/library/asyncio-task.html#waiting-primitives
但是医生说:
Run awaitable objects in the aws set concurrently and block until the condition specified by return_when.
这似乎表明它会阻止......
似乎 asyncio.wait_for 可以解决问题 https://docs.python.org/3/library/asyncio-task.html#timeouts 但是我如何发送等待列表而不是等待列表?
【问题讨论】: