Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid nested KeyError exception for threaded_cached_property #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spyoungtech
Copy link

@spyoungtech spyoungtech commented Oct 23, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

threaded_cached_property can raise confusing exception
1 participant