I'm using asyncio to await set of coroutines in following way:
# let's assume we have fn defined and that it can throw an exception
coros_objects = []
for x in range(10):
coros_objects.append(fn(x))
for c in asyncio.as_completed(coros_objects):
try:
y = await c
exception:
# something
# if possible print(x)
Question is how can I know which coroutine failed and for which argument?
I could append "x"
to the outputs but this would give me info about successful executions only.
I can know that form order because it's different from the order of coros_objects
Can I somehow identify what coro just yielded result?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…