From 6b9138cf8d3906f1948fec1d9964210738c0ebd5 Mon Sep 17 00:00:00 2001 From: Spencer Phillip Young Date: Sat, 23 Oct 2021 15:04:02 -0700 Subject: [PATCH] Avoid nested KeyError exception for threaded_cached_property --- cached_property.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cached_property.py b/cached_property.py index 3135871..f50005e 100644 --- a/cached_property.py +++ b/cached_property.py @@ -70,8 +70,9 @@ def __get__(self, obj, cls): return obj_dict[name] except KeyError: - # if not, do the calculation and release the lock - return obj_dict.setdefault(name, self.func(obj)) + pass + # if not, do the calculation and release the lock + return obj_dict.setdefault(name, self.func(obj)) class cached_property_with_ttl(object):