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
Create a lock on cached_property if not present #1811
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the patch. do you think the change should be covered with some unit tests at least?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are hit by a test failure with python 3.12 here #1812 (comment), was thinking if this change going to fix that? or we need to update the test as well?
Yes, I should be able to add a test to verify that locks are held as needed.
That looks like a different issue, though I didn't look at the test very closely. |
Added a test that verifies the lock is acquired for all of get, set, and delete operations. I could also test that the lock is held at appropriate times, but opted not to do that since it would require doing a threading dance in the test to verify; just ensuring that the operations acquire the lock seems fine. |
This fixes celery#1804 (fixing breakage caused by use of undocumented implementation details of functools.cached_property) by ensuring a lock is always present on cached_property attributes, which is required to safely support setting and deleting cached values in addition to computing them on demand.
6d8e93e
to
8c169b1
Compare
This fixes #1804 (fixing breakage caused by use of undocumented implementation details of functools.cached_property) by ensuring a lock is always present on cached_property attributes, which is required to safely support setting and deleting cached values in addition to computing them on demand.