Skip to main content

py-rwmutex

This package provides a simple read/write mutex lock for threads, based upon the threading package. It supports Python's context manager interface, so it may be used within with statements.

Purpose

This read/write lock can improve performance by allowing multiple threads to reaad from a shared resource at once. For safety, only one thread is granted a write lock at a time, and only when no threads have a read lock.

Installation

This package is available from PyPi, which means it can be easily acquired via pip.

Run this command at a shell prompt:

pip3 install rwmutex

Usage

To get started, import the package like so:

from rwmutex import RWLock

Then you can declare a lock object:

lock = RWLock()

To use the lock, you can use with blocks:

with lock.write
    # some operation that writes
    pass

with lock.read:
    # some operation that just needs to read
    pass

For a working example, see example.py.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rwmutex-1.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rwmutex-1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file rwmutex-1.1.tar.gz.

File metadata

  • Download URL: rwmutex-1.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.3

File hashes

Hashes for rwmutex-1.1.tar.gz
Algorithm Hash digest
SHA256 b8fdc87810aa6b0b7b4c02c1612cc66141e91bd45bad8556e3305cdc2123d393
MD5 55d8646116a685063c434fb5a6b867ea
BLAKE2b-256 7bd7bbbdf48e9f55189533337adfcfa9fa3211a9dab9a1122dca5f0dc22ccc5d

See more details on using hashes here.

File details

Details for the file rwmutex-1.1-py3-none-any.whl.

File metadata

  • Download URL: rwmutex-1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.3

File hashes

Hashes for rwmutex-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69a8256ccbd0e061fc8c14892d8d2b3b64d8d8c7b8e6f1abbd607c5147cfb6c7
MD5 53975b66999086cca9e6d7cabadd0642
BLAKE2b-256 139ba1105cb2e6a67d9019563c3240da6a2111112a092799c31ce0017d527f70

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1 This release

2 files

1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page