Message413816
I think that it would be simpler to add a decorator which wraps the result of an asynchronous function into an object which can be awaited more than once:
def reawaitable(func):
@wraps(func)
def wrapper(*args, **kwargs):
return CachedAwaitable(func(*args, **kwargs))
return wrapper
It can be combined with lru_cache and cached_property any third-party caching decorator. No access to internals of the cache is needed.
@lru_cache()
@reawaitable
async def coro(...):
...
@cached_property
@reawaitable
async def prop(self):
... |
|
| Date |
User |
Action |
Args |
| 2022-02-23 16:39:43 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, asvetlov, yselivanov, uranusjr |
| 2022-02-23 16:39:43 | serhiy.storchaka | set | messageid: <[email protected]> |
| 2022-02-23 16:39:43 | serhiy.storchaka | link | issue46622 messages |
| 2022-02-23 16:39:42 | serhiy.storchaka | create | |
|