[docs] [issue27589] asyncio doc: issue in as_completed() doc
Hynek Schlawack
report at bugs.python.org
Tue Nov 8 11:26:18 EST 2016
Hynek Schlawack added the comment:
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. :)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27589>
_______________________________________
More information about the docs
mailing list