[issue46622] Support decorating a coroutine with functools.cached_property
Tzu-ping Chung
report at bugs.python.org
Thu Feb 10 04:23:17 EST 2022
Tzu-ping Chung <uranusjr at gmail.com> added the comment:
> should not use asyncio directly but 'async def', 'await', and `inspect.iscoroutine()` / `inspect.iscoroutinefunction()` instead.
Hmm, this introduces some difficulties. Since a coroutine can only be awaited once, a new coroutine needs to be returned (that simply return the result when awaited) each time __get__ is called. But this means we need a way to somehow get the result in __get__. If there’s a separate `cached_property_async` it’s possible to make __get__ a coroutine function, but personally I’d prefer the interface to match the PyPI cached_property.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46622>
_______________________________________
More information about the Python-bugs-list
mailing list