[issue35040] functools.lru_cache does not work with coroutines

2018-10-22 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

A coroutine detection is a relatively slow check.
I don't think we need to do it in `functools.lru_cache`.

There is a specialized asyncio compatible version: 
https://github.com/aio-libs/async_lru
Please use it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35040] functools.lru_cache does not work with coroutines

2018-10-21 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35040] functools.lru_cache does not work with coroutines

2018-10-21 Thread Liran Nuna


New submission from Liran Nuna :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com