Serhiy Storchaka <[email protected]> added the comment:
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):
...
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46622>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com