-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Allow multiple readers #58
Comments
For the benefit of searchability, this is also called a readers-writers-lock, or an RW-lock. |
I would be interested in the same thing. Implementation-wise, it would be possible to do this on top of the current classes: One could have a regular filelock around a shared file that contains the current number of readers / a writer flag. However, that would require three files, and some code would need to compose three corresponding filenames. Hence, if it was possible to have such a simple API as suggested above, that would be welcome! |
Are there alternative terms to be considered? I like mode = "reader" / "writer", but could also imagine "shared" / "exclusive", for instance. |
Hello, if you make a PR for this (with tests) we would be happy to review, thanks! |
Is there a way to add an argument to the LockFile class, such as "writer" or "reader", in order to:
allow multiple readings between processes and threads (like
with LockFile("file.txt", mode="reader"):
) avoiding writingnot allow readings while writing (like
with LockFile("file.txt", mode="writer"):
)Thanks
Edit: the operations are not referred to the file "file.txt", that file is just used as a locker.
The text was updated successfully, but these errors were encountered: