Any idea how I could get these args?
A straightforward approach is to attach them to the task before calling wait()
:
todo = []
for arg in 10, 20, 20, 30:
task = asyncio.create_task(f(arg))
task.f_arg = arg
todo.append(task)
done, pending = await asyncio.wait(todo, timeout=2.5)
# creation arg available in `f_arg` regardless of whether the task
# is done or pending
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…