Skip to main content

A comprehensive python library for synchronization proxies

Project description

Door is a comprehensive python library for synchronization proxies. Door’s reliability has been established through static type checking, extensive doctests, and unit tests, achieving 83% code coverage.

Features

  • Synchronization proxies to enforce sound synchronous data access.

    • Supported scenarios:

      • Multithreading;

      • Asynchronous programming.

    • Supported primitives:

      • Lock;

      • RLock;

      • Condition;

      • Semaphore;

      • BoundedSemaphore;

      • RSLock (Read-preferring shared lock);

      • WSLock (Write-preferring shared lock);

      • et cetera.

  • Shared lock (Readers-writer lock) implementations.

    • Supported scenarios:

      • Multithreading;

      • Multiprocessing;

      • Asynchronous programming.

Installation

pip install door

Usage

Below shows a sample usage of Door.

>>> @dataclass
... class Resource:
...     key: Any = 'value'
...
>>> resource = Resource()
>>> resource
Resource(key='value')
>>> resource.key
'value'
>>> from door.threading2 import RSLock
>>> door = SAcquirableDoor(resource, RSLock())
>>> with door.read() as proxy:
...     proxy.key
...
'value'
>>> with door.read() as proxy:
...     proxy.key = 'VALUE'
...
Traceback (most recent call last):
    ...
ValueError: no write permission
>>> with door.write() as proxy:
...     proxy.key
...     proxy.key = 'VALUE'
...     proxy.key
...
'value'
'VALUE'
>>> proxy.key
Traceback (most recent call last):
    ...
ValueError: no read permission
>>> proxy.key = 'value'
Traceback (most recent call last):
    ...
ValueError: no write permission
>>> resource
Resource(key='VALUE')
>>> resource.key
'VALUE'

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

door-0.0.2.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

door-0.0.2-py3-none-any.whl (12.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page