<div dir="ltr">You can try to place these in a separate module, but in the end they still depend on asyncio. You'll find out why when you try to implement any of them. Don't dismiss the effort that went into asyncio too lightly.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 2, 2015 at 3:18 PM, Piotr Jurkiewicz <span dir="ltr"><<a href="mailto:piotr.jerzy.jurkiewicz@gmail.com" target="_blank">piotr.jerzy.jurkiewicz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I know that. But the problem with wait() is that it returns Tasks, not their results directly. So user has to unpack them manually.<br>
<br>
Furthermore, after introduction of `await`, its name will become problematic. It will reassembles `await` too much and can cause a confusion. Its usage would result in an awkward 'await wait()'.<br>
<br>
There is a function gather(*coros_or_futures) which returns results list directly, like the function all_done() I proposed.<br>
<br>
But there is no function gather_any(*coros_or_futures), to return just a result of the first done coroutine. (One can achieve it with wait(return_when=FIRST_COMPLETED) but as mentioned before, it does not return a result directly, so there is no symmetry with gather())<br>
<br>
Function as_completed() returns indeed an iterator over the futures as they complete, but it is not compatible with the 'async for' protocol proposed in PEP 492. So new function has to be created anyway.<br>
<br>
Therefore I deliberately placed these functions in a new asynctools module, not in the asyncio module: to emphasize that they are supposed to be used with the new-style coroutines, proposed in PEP 492.<br>
<br>
I wanted to achieve simplicity (by returning results directly) and symmetry (all_done()/any_done()).<span class="HOEnZb"><font color="#888888"><br>
<br>
Piotr</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 2015-05-02 23:29, Guido van Rossum wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The asyncio package already has this functionality; check out wait() (it<br>
has various options), as_completed(), gather().<br>
</blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>