A comprehensive python library for advanced synchronizationmechanisms
Project description
Door is a comprehensive python library for advanced synchronization mechanisms. Door’s reliability has been established through static type checking, extensive doctests, and unit tests, achieving 100% code coverage.
Features
Data access system to enforce sound synchronous data access.
SLock (Readers-writer lock) implementations.
Supported scenarios:
Multithreading;
Multiprocessing;
Asynchronous programming.
Supported primitives:
Lock;
RLock;
Condition;
Semaphore;
BoundedSemaphore;
SLock (Readers-writer lock);
et cetera.
Installation
pip install door
Usage
Below shows a sample usage of Door.
>>> from dataclasses import dataclass
>>> from door import Door
>>> from threading import RLock
>>> @dataclass
... class X:
... a: str = 'a'
... b: str = 'b'
...
>>> x = X()
>>> x
X(a='a', b='b')
>>> x.a
'a'
>>> x.b
'b'
>>> door = Door(x, RLock())
>>> with door.read() as resource:
... resource.a
...
'a'
>>> resource.a
Traceback (most recent call last):
...
ValueError: no read permission
>>> resource.a = 'A'
Traceback (most recent call last):
...
ValueError: no write permission
>>> with door.read() as resource:
... resource.a = 'A'
...
Traceback (most recent call last):
...
ValueError: no write permission
>>> with door.write() as resource:
... resource.b = 'B'
... resource.b
... resource.a
... resource.a = 'A'
... resource.a
...
'B'
'a'
'A'
>>> x
X(a='A', b='B')
>>> x.a
'A'
>>> x.b
'B'
Testing and Validation
Door has extensive test coverage, passes mypy static type checking with strict parameter, and has been validated through extensive use in real-life scenarios.
Contributing
Contributions are welcome! Please read our Contributing Guide for more information.
License
Door is distributed under the MIT license.
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
Built Distribution
File details
Details for the file door-0.0.0.tar.gz
.
File metadata
- Download URL: door-0.0.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d63dbbeeb308a61ddfc748290369bdd848e30b5f2e64d7853fbaa74a02703aff |
|
MD5 | c747d77ad42a63ec28f8d08823d8e176 |
|
BLAKE2b-256 | b0e7d50d97ec4b0c5b60920b88d153ed5297e179ab81e6159d6f54bbb9e69c82 |
File details
Details for the file door-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: door-0.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0de41af45fcfb9c23c93a44832d6bc0ad72f87d5b9b299677d261c8a8864ff00 |
|
MD5 | 58fb2278e65b8aee7dfd79ff684e59c2 |
|
BLAKE2b-256 | 97a6ecd69d165c1b8d96ca6fad0be5b8f92feaad37dc3dd1458edc6254f82d2a |