New submission from Liran Nuna <liran...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue35040>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to