This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lordmauve
Recipients lordmauve
Date 2021-08-20.17:24:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The anext_awaitable object returned by anext(..., default) does not support .send()/.throw(). It only supports __next__().

So we can pass messages from the suspending coroutine to the event loop but not from the event loop to the suspending coroutine.

trio and curio rely on both directions working. (I don't know about asyncio.)

For example, this trio code fails:

    import trio

    async def produce():
       for v in range(3):
           await trio.sleep(1)
           yield v

    async def consume():
       p = produce()
       while True:
            print(await anext(p, 'finished'))

raising AttributeError: 'anext_awaitable' object has no attribute 'send'.

I realise that any awaitable that wants to await another awaitable must return not an iterator from __await__() but something that implements the full PEP-342 generator protocol. Should PEP-492 section on __await__()[1] say something about that?

Date User Action Args
2021-08-20 17:24:00lordmauvesetrecipients: + lordmauve
2021-08-20 17:24:00lordmauvesetmessageid: <>
2021-08-20 17:24:00lordmauvelinkissue44963 messages
2021-08-20 17:24:00lordmauvecreate