-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support reentrant locking on lock file path via optional singleton instance #283
Support reentrant locking on lock file path via optional singleton instance #283
Conversation
Downloading pypy locally to investigate test failures. |
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.
Don't disable ruff checks, address them.
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
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 so much for the help! |
I think there might be a bug: all derived class of BaseFileLock share the same from filelock import UnixFileLock, BaseFileLock
assert UnixFileLock._instances is BaseFileLock._instances This can be resolved by meta class or simpler |
BTW, maybe we should check if args like |
@YouJiacheng good callout. I think I avoided a metaclass in the first place because Checking mode and timeout don't seem particularly relevant if we determine two singleton locks are the sam object (so will have the same values), unless you meant something else there. |
Okay, By checking |
@YouJiacheng here is the fix using As for the other question, deciding on how to handle that seems like something for @gaborbernat to decide on. We could:
|
Would be my vote. |
Fix for incompatible singleton args: #320. |
Description
Re: #282.
_singleton_per_lock_file
is set instantiating a new lock with the same lock path will return the existing instance of the lock. This means you can reacquire the lock without passing the lock object aroundBased on the
flock
docs (and likely similar for windows/soft cases)(https://man7.org/linux/man-pages/man2/flock.2.html)
a Python solution seems most general and easy here. If anyone has time to dig into different OS file locking mechanisms and see if there is a native solution that would likely be preferable.
Action Items