<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 27, 2017 at 1:12 AM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, 27 Nov 2017 00:41:55 -0800<br>
Nathaniel Smith <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br>
><br>
> Since most libraries assume that they control both __await__ and the<br>
> coroutine runner, they don't tend to give great error messages here<br>
> (though trio does [2] ;-)). I think this is also why the asyncio docs<br>
> don't talk about this. I guess in asyncio's case it is technically a<br>
> semi-public API because you need to know how it works if you're the<br>
> author of a library like tornado or twisted that wants to integrate<br>
> with asyncio. But most people aren't the authors of tornado or<br>
> twisted, and the ones who are already know how this works, so the lack<br>
> of docs isn't a huge deal in practice...<br>
<br>
</span>This does seem to mean that it can be difficult to provide a __await__<br>
method that works with different coroutine runners, though. For<br>
example, Tornado Futures implement __await__ for compatibility with the<br>
asyncio event loop. But what if Tornado wants to make its Future class<br>
compatible with an event loop that requires a different __await__<br>
convention?<br></blockquote><div><br></div><div>Someone would have to write a PEP proposing a standard interoperability API for event loops.</div><div><br></div><div>There is already such a PEP (PEP 3156, which standardized the asyncio event loop, including the interop API) but curio and trio intentionally set out to invent their own conventions. At least asyncio has an API that allows overriding the factory for Futures, so if someone comes up with a Future that is interoperable between asyncio and curio, for example, it might be possible. But likely curio would have to be modified somewhat too.<br></div></div><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>