Reader Writer Lock
Project description
ReaderWriterLock
This Python package addresses the reader-writer problems. It supports both multithreading and multiprocessing environment in Python.
The package is implemented based on a RLock and 2 Condition Variables
Refer to Wikipedia for full detail about reader-writer lock.
Installation
pip install reader-writer-locks
Usage
- Choose between the following
option
| Priority Policies | option |
|---|---|
| Not specified | 0 |
| Reader priority | 1 |
| Writer priority | 2 |
- Instantiate locks based on the chosen
option
# in case of multithreading usage
from reader_writer_lock import MultithreadingFactory
rw = MultithreadingFactory(option)
r_lock = rw.get_read_lock()
w_lock = rw.get_write_lock()
# in case of multiprocessing usage
from reader_writer_lock import MultiprocessingFactory
# same as multi threading cases
- Use the generated lock to protect critical sections Pythonic usage
with r_lock:
# Read
with w_lock:
# Write
Future work
- To avoid starvation problem. (As the Condition Object in Python does not work in FIFO manner)
- To add blocking & timeout interface, which follows the RLock interface
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reader_writer_locks-0.0.3.tar.gz.
File metadata
- Download URL: reader_writer_locks-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f29d71c6f86d8f6563a1dbfc6dced0ef168250ac44100b4dbda6dbb3a6f035f
|
|
| MD5 |
dad860c06b29e4b033472e7c0840da71
|
|
| BLAKE2b-256 |
7aaae9f29d9d9acb2d051ece377324f19e761036c28893b6e73aaec430014d10
|
File details
Details for the file reader_writer_locks-0.0.3-py3-none-any.whl.
File metadata
- Download URL: reader_writer_locks-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aade76aaa4570685b9a24c1d66010c0edddf434fca6301a03961cd68012b75b6
|
|
| MD5 |
4af32794f0b626e8532395983e902932
|
|
| BLAKE2b-256 |
828b9841d3660a0db2ba06ddd41d3c56d77c602f6ee6dee363977ed37bbdc1bd
|