We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add cache in a async function?
import asyncio from pathlib import Path from beaker.cache import CacheManager from beaker.util import parse_cache_config_options cache_opts = { 'cache.type': 'file', 'cache.data_dir': Path(__file__).parent / 'cache/data', 'cache.lock_dir': Path(__file__).parent / 'cache/lock' } cache = CacheManager(**parse_cache_config_options(cache_opts)) # @cache.cache('fib', type='file', expire=60*5) async def fib(n): if n < 2: return n return await fib(n - 1) + await fib(n - 2) async def main(): result = [await fib(i) for i in range(35)] print(result) if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(main())
It caused RuntimeWarning: coroutine 'fib' was never awaited.
RuntimeWarning: coroutine 'fib' was never awaited
Looking for your reply! Thank you.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
How to add cache in a async function?
It caused
RuntimeWarning: coroutine 'fib' was never awaited
.Looking for your reply! Thank you.
The text was updated successfully, but these errors were encountered: