<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 22, 2015 at 5:12 PM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Guido van Rossum wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Apr 22, > OTOH I'm still struggling with what you have to do to wrap a coroutine in a Task, the way its done in asyncio by the Task() constructor, the loop.create_task() method, and the async() function<br>
</blockquote>
<br>
That's easy. You can always use costart() to adapt a cofunction<br>
for use with something expecting a generator-based coroutine,<br>
e.g.<br>
<br>
codef my_task_func(arg):<br>
  ...<br>
<br>
my_task = Task(costart(my_task_func, arg))<br>
<br>
If you're willing to make changes, Task() et al could be made to<br>
recognise cofunctions and apply costart() where needed.<span class="HOEnZb"><font color="#888888"></font></span></blockquote><div> </div></div>Hm, that feels backwards incompatible (since currently I can write Task(my_task_func(arg)) and also a step backwards in elegance (having to pass the args separately).<br><br></div><div class="gmail_extra">OTOH the benefit is that it's much harder to accidentally forget to wait for a coroutine. And maybe the backward compatibility issue is not really a problem because you have to opt in by using codef or async def.<br><br></div><div class="gmail_extra">So I'm still torn. :-)<br><br></div><div class="gmail_extra">Somebody would need to take a mature asyncio app and see how often this is used (i.e. how many place would require adding costart() as in the above example).<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>