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

Read/Write lock for PickledDB #276

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mnoukhov
Copy link
Collaborator

I worked off of https://github.com/elarivie/pyReaderWriterLock/ to make a wrapper for FileLock that allows for multiple readers but only one writer at a time

WIP, still need to test

@bouthilx
Copy link
Member

🎊 Thanks a lot! Let me know when it is ready for review. :)

working normally
@Thomsch
Copy link
Contributor

Thomsch commented Mar 5, 2020

@mnoukhov @bouthilx Is there a status update on this contribution?

@mnoukhov
Copy link
Collaborator Author

mnoukhov commented Mar 6, 2020

Ah sorry. I never got around to writing tests for R/W concurrency. If you send me a pointer to one, I'd happily do it

@Thomsch
Copy link
Contributor

Thomsch commented Mar 6, 2020

No worries, thanks for the update. @bouthilx should be able to give you a pointer. I'll check with him next week.

@bouthilx
Copy link
Member

bouthilx commented Mar 9, 2020

Unittests with concurrency 😰 😅 I don't see any way you can do this without using python multithreading/multiprocessing. One simple test for the locking would be to have n threads/process with a DB having a single data point {'n': 0}, all readers do read_and_write(query={'n': worker_n}, data={'n': worker_n+1}) until the DB reaches 'n' == num_workers and you verify that you actually went through the sequence (0, 1, 2, 3, ...).

But that's only testing the atomicity of write/read, not number of concurrent readers. For testing number of concurrent readers, I would hardcode a scenario where there is one writer and N readers and mock open to force read some valid or invalid numbers of readers and confirm it is handled properly.

@Thomsch Thomsch marked this pull request as draft May 4, 2020 16:56
@Thomsch Thomsch changed the title [WIP] Read/Write lock for PickledDB Read/Write lock for PickledDB May 4, 2020
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.

3 participants