[New-bugs-announce] [issue35040] functools.lru_cache does not work with coroutines
Liran Nuna
report at bugs.python.org
Sun Oct 21 21:39:51 EDT 2018
New submission from Liran Nuna <liranuna at gmail.com>:
lru_cache is a very useful method but it does not work well with coroutines since they can only be executed once.
Take for example, the attached code (test-case.py) - It will throw a RuntimeError because you cannot reuse an already awaited coroutine.
A solution would be to call `asyncio.ensure_future` on the result of the coroutine if detected.
----------
components: asyncio
files: test-case.py
messages: 328228
nosy: Liran Nuna, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: functools.lru_cache does not work with coroutines
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file47887/test-case.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35040>
_______________________________________
More information about the New-bugs-announce
mailing list