cached-property
cached-property copied to clipboard
Avoid nested KeyError exception for threaded_cached_property
Resolves #260
Uses similar approach to the cached_property_with_ttl
decorator.
Using the same example from #260 the exception no longer contains a KeyError
:
Traceback (most recent call last):
File "t.py", line 15, in <module>
m.boardwalk
File "/Users/spencer.young/repos/cached-property/cached_property.py", line 75, in __get__
return obj_dict.setdefault(name, self.func(obj))
File "t.py", line 11, in boardwalk
self.boardwalk_price += 1/0
ZeroDivisionError: division by zero
Hopefully this will reduce confusion for users, such as in situations like this.