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 GeeTransit
Recipients GeeTransit
Date 2019-08-06.01:20:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565054430.97.0.58176402921.issue37771@roundup.psfhosted.org>
In-reply-to
Content
In PEP 525, async generators were introduced. They use `.asend()` and `.athrow()` methods that return a "coroutine-like" object - specifically, a PyAsyncGenASend and PyAsyncGenAThrow respectively.

While these "coroutine-like" object implement `.send()`, `.throw()`, and `.close()`, they don't provide any attributes like normal coroutine objects do such as `cr_running` or `cr_await`.

When I use `inspect.getcoroutinestate()`, it raises an AttributeError on how there isn't a `cr_running` attribute / flag.

There is a workaround I use which is to wrap it with another coroutine as below:

>>> async def async_generator():
...     yield
...
>>> async def wrap_coro(coro):
...     return await coro
>>> agen = async_generator()
>>> asend = wrap_coro(agen.asend(None))

This seems like something that should be changed to make it more inline with normal coroutines / awaitables.
History
Date User Action Args
2019-08-06 01:20:31GeeTransitsetrecipients: + GeeTransit
2019-08-06 01:20:30GeeTransitsetmessageid: <1565054430.97.0.58176402921.issue37771@roundup.psfhosted.org>
2019-08-06 01:20:30GeeTransitlinkissue37771 messages
2019-08-06 01:20:30GeeTransitcreate