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
Misc improvements #18
Conversation
gsakkis
commented
Apr 19, 2015
- Fixed threaded_cached_property_with_ttl to actually be thread-safe.
- Allow the del statement for resetting cached properties with ttl instead of del obj._cache[attr].
- Overall code and test refactoring.
- Fix shadowed Testcase class name in test_cached_property_ttl - Single Testcase class per cached_property variant. - Make test modules non-executable.
…o it. dict.setdefault() is atomic since three years ago; see http://bugs.python.org/issue13521
Looks like TravisCI uncovered a pypy bug; I opened an issue for it here. |
…as wrong. Although the previous commit correctly cached and returned only the first computed value (since dict.setdefault() is atomic), the actual computation could be performed more than once in multithreaded environment, with all but the first computed values being discarded.
I love this pull request, I really do! Do we know when the PyPy error fix will make it to a formal release? |
As a workaround for the PyPy bug it would be possible to add a |
@gsakkis Adding the |
Cache (value, time) in the object's __dict__ instead of doing an extra lookup in a '_cache' dict; also avoids the potential name clash with an unrelated attribute named '_cache'.
…settable just like cached_property/threaded_cached_property
It turned out to be somewhat trickier. Before adding the So for the sake of consistency and backwards compatibility, I added a |
All tests pass at last! Btw I fixed |
I will probably cut a release tomorrow. Right now am working towards an epic Friday deadline. |
Great, no rush. If you can wait for a day or two I have another feature PR in mind. |