This commit is contained in:
Miroslav Stampar
2019-02-12 10:49:47 +01:00
parent ba883b77df
commit dfe6fe6060
3 changed files with 5 additions and 4 deletions

View File

@@ -27,7 +27,8 @@ def cachedmethod(f, cache=LRUDict(capacity=MAX_CACHE_ITEMS)):
key = int(hashlib.md5("|".join(str(_) for _ in (f, args, kwargs))).hexdigest(), 16) & 0x7fffffffffffffff
try:
result = cache[key]
with _lock:
result = cache[key]
except KeyError:
result = f(*args, **kwargs)