Message349093
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. |
|
Date |
User |
Action |
Args |
2019-08-06 01:20:31 | GeeTransit | set | recipients:
+ GeeTransit |
2019-08-06 01:20:30 | GeeTransit | set | messageid: <1565054430.97.0.58176402921.issue37771@roundup.psfhosted.org> |
2019-08-06 01:20:30 | GeeTransit | link | issue37771 messages |
2019-08-06 01:20:30 | GeeTransit | create | |
|