A limited re-entrant readwrite lock
Project description
This is rwrlock a yet another python re-entrant rw lock
Goals
- To make a rentrant read write lock as opposed to non re-entrant
- Within one thread multiple readlocks can be obtained in reality only first in stack takes lock restreference count
- Within onethreadmultiple write locks can be obtained again first gets lock restreference count
- Within one thread if you want a read lock and have a write lock it acts as if read lock is obtained but keeps the write lock
- Wihin one thread if you have a read lock and want a write lock read lock is dropped a write lock acquired. But when write is release the read lock is reobtained. This can lead to read consistency issues if not used carefuly.
This does not implement and priority between readers and writers
Usage:
from rwrlock import RWRLock
my_obj_rwlock = RWRLock()
# When reading from my_obj:
with my_obj_rwlock.r_locked():
do_read_only_things_with(my_obj)
# promote to a write lock
with my_obj_rwlock.w_locked():
mutate(my_obj)
# When writing to my_obj:
with my_obj_rwlock.w_locked():
mutate(my_obj)
# ok do to do read things as has a write lock
with my_obj_rwlock.r_locked():
do_read_only_things_with(my_obj)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rwrlock-0.0.5.tar.gz
(7.4 kB
view details)
Built Distribution
File details
Details for the file rwrlock-0.0.5.tar.gz
.
File metadata
- Download URL: rwrlock-0.0.5.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.18.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd3400249cef04c08d938914d664a4f487d8050c627edfe66842137cb17617fc |
|
MD5 | abae8a004e4397670dba48afefc9a705 |
|
BLAKE2b-256 | cd15a886aed8227f05f77e569cd6e8273bc137cd9adbbe8654c7bfb9a6e5ea59 |
File details
Details for the file rwrlock-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: rwrlock-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.18.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00a18ad8628491be78fc77005aecdcb882baca1949e42964bcaa5e1824870a26 |
|
MD5 | abe3948439930eccd45a14284e4ac87e |
|
BLAKE2b-256 | eb4eb2261f9b32ab061b02bd8968a0e43014103e6b1d729cd76539d94ddfb681 |