Merge branch 'feature/UpdateLruCache' into dev

This commit is contained in:
JackDandy 2023-02-09 14:41:33 +00:00
commit da008063f3
2 changed files with 5 additions and 4 deletions
CHANGES.md
lib/backports/functools_lru_cache

View file

@ -10,6 +10,7 @@
* Update chardet packages 4.0.0 (b3d867a) to 5.1.0 (8087f00)
* Update diskcache 5.1.0 (40ce0de) to 5.4.0 (1cb1425)
* Update feedparser 6.0.1 (98d189fa) to 6.0.10 (5fcb3ae)
* Update functools_lru_cache 1.6.1 (2dc65b5) to 1.6.2 (2405ed1)
* Update humanize 3.5.0 (b6b0ea5) to 4.0.0 (a1514eb)
* Update Js2Py 0.70 (92250a4) to 0.74 (2e017b8)
* Update pyjsparser 2.7.1 (5465d03) to 2.7.1 (cbd1e05)

View file

@ -4,7 +4,7 @@ import functools
from collections import namedtuple
from threading import RLock
_CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"])
_CacheInfo = namedtuple("_CacheInfo", ["hits", "misses", "maxsize", "currsize"])
@functools.wraps(functools.update_wrapper)
@ -63,7 +63,7 @@ def _make_key(
return _HashedSeq(key)
def lru_cache(maxsize=100, typed=False):
def lru_cache(maxsize=100, typed=False): # noqa: C901
"""Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
@ -136,7 +136,7 @@ def lru_cache(maxsize=100, typed=False):
if link is not None:
# record recent use of the key by moving it
# to the front of the list
root, = nonlocal_root
(root,) = nonlocal_root
link_prev, link_next, key, result = link
link_prev[NEXT] = link_next
link_next[PREV] = link_prev
@ -148,7 +148,7 @@ def lru_cache(maxsize=100, typed=False):
return result
result = user_function(*args, **kwds)
with lock:
root, = nonlocal_root
(root,) = nonlocal_root
if key in cache:
# getting here means that this same key was added to the
# cache while the lock was released. since the link