Message280315
Such an idiom is IMHO not the main usefulness of this function tho.
As an (untested) example, something like
async def f(n):
await asyncio.sleep(n)
return n
for f in asyncio.as_completed([f(3), f(2), f(1)]):
print(await f)
will print:
1
2
3
That’s *super* useful if you’re coordinating multiple independent external systems and need to process their results as soon as they arrive (and not once they’re *all* done).
Maybe it always worked by accident for me but it’s my understanding, that that is what this function is for (and I haven’t found another way to achieve it).
That’s why it would be nice if there’d be authoritative docs on what it’s supposed to do. :) |
|
Date |
User |
Action |
Args |
2016-11-08 16:26:18 | hynek | set | recipients:
+ hynek, gvanrossum, vstinner, aronacher, docs@python, yselivanov |
2016-11-08 16:26:18 | hynek | set | messageid: <1478622378.55.0.352245281074.issue27589@psf.upfronthosting.co.za> |
2016-11-08 16:26:18 | hynek | link | issue27589 messages |
2016-11-08 16:26:18 | hynek | create | |
|