This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients asvetlov, rhettinger, serhiy.storchaka, uranusjr, yselivanov
Date 2022-02-14.14:35:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644849352.23.0.647319191588.issue46622@roundup.psfhosted.org>
In-reply-to
Content
Note that there is a similar issue with cached generators.

>>> from functools import *
>>> @lru_cache()
... def g():
...     yield 1
... 
>>> list(g())
[1]
>>> list(g())
[]

I am not sure that it is safe to detect awaitables and iterables in caching decorators and automatically wrap them in re-awaitable and re-iterable objects. But we can add explicit decorators and combine them with arbitrary caching decorators. For example:

@lru_cache()
@reiterable
def g():
    yield 1
History
Date User Action Args
2022-02-14 14:35:52serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, asvetlov, yselivanov, uranusjr
2022-02-14 14:35:52serhiy.storchakasetmessageid: <1644849352.23.0.647319191588.issue46622@roundup.psfhosted.org>
2022-02-14 14:35:52serhiy.storchakalinkissue46622 messages
2022-02-14 14:35:52serhiy.storchakacreate