A python implementation of the three Reader-Writer problems.
Project description
A python implementation of the three Reader-Writer problems.
Not only does it implement the reader-writer problems, it is also compliant with the python lock interface which includes support for timeouts.
For reading about the theory behind the reader-writer problems refer to Wikipedia.
Installation
Install the python package readerwriterlock
python3 -m pip install readerwriterlock
Usage
Initialize a new lock base on your access priority need which is going to be use by the threads:
Reader priority (aka First readers-writers problem)
from readerwriterlock import rwlock a = rwlock.RWLockRead()
Writer priority (aka Second readers-writers problem)
from readerwriterlock import rwlock a = rwlock.RWLockWrite()
Fair priority (aka Third readers-writers problem)
from readerwriterlock import rwlock a = rwlock.RWLockFair()
Pythonic usage example
with a.gen_rlock():
#Read stuff
with a.gen_wlock():
#Write stuff
Advanced Usage example
b = a.gen_wlock()
if b.acquire(blocking=True, timeout=5):
#Do stuff
b.release()
Live example
Refer to the file rwlock_test.py which can be directly called, it has above 90% line coverage of rwlock.py.
The tests can be initiated by doing
./rwlock_test.py
Build
This project use the BUILDME interface, you may therefore build the project by simply doing:
./BUILDME
Contribute
You are the welcome to contribute.
Contact
- Project:
- Bug tracker:
- Author:
Éric Larivière ericlariviere@hotmail.com
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 readerwriterlock-1.0.4.tar.gz.
File metadata
- Download URL: readerwriterlock-1.0.4.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea9a433924cbf50f56bd3487c46ee09251f69ebf44217d5c331c16577b15a9d
|
|
| MD5 |
5f095b8688ea665cee553b825b186a4a
|
|
| BLAKE2b-256 |
178e66256c540b21bdc18ce46abe1b2294ea6b167a9cde8cd58ef62a0cd0cf3f
|
File details
Details for the file readerwriterlock-1.0.4-py3-none-any.whl.
File metadata
- Download URL: readerwriterlock-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a97d372daa5bcd7749460603cc097f4126b1ff17f71ef99c89cdba1d06d366
|
|
| MD5 |
ba04e2f74d03a7bccc2aa025f917fa1d
|
|
| BLAKE2b-256 |
989a1d885282ee8d3b54991490ff2db441c65c97e7cc404d08c2495029085cf4
|