New submission from GeeVye <geetran...@gmail.com>:
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. ---------- components: Demos and Tools messages: 349093 nosy: GeeVye priority: normal severity: normal status: open title: No equivalent of `inspect.getcoroutinestate` for PyAsyncGenASend instances type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37771> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com