Re: [Python-Dev] Implementing an awaitable

2018-11-07 Thread Justin Turner Arthur
Thanks for the thorough rundown, Nathaniel. I started to get an idea of the required shape only by looking at CPython code like you suggest. I wanted to create an awaitable compatible with asyncio and trio that could be awaited more than once unlike a coroutine, and not runner-specific like a

Re: [Python-Dev] Implementing an awaitable

2018-11-07 Thread Nathaniel Smith
"Awaitable" is a language-level concept. To actually use awaitables, you also need a coroutine runner library, and each library defines additional restrictions on the awaitables it works with. So e.g. when using asyncio as your coroutine runner, asyncio expects your awaitables to follow particular

[Python-Dev] Implementing an awaitable

2018-11-07 Thread Justin Turner Arthur
I'm trying to figure out if our documentation on the new awaitable concept in Python 3.6+ is correct. It seems to imply that if an object's __await__ method returns an iterator, the object is awaitable. However, just returning an iterator doesn't seem to work with await in a coroutine or with the