Skip to main content

Exclusive and shared locking

Project description

Intro

The SELock is a shared/exclusive lock that you can use to coordinate read and write access to a resource in a multithreaded application.

Example:

use SELock to coordinate access to a resource

>>> from scottbrian_locking import se_lock as sel
>>> a_lock = sel.SELock()
>>> # Get lock in exclusive mode
>>> with sel.SELockExcl(a_lock):
...     msg = 'lock obtained exclusive'
>>> print(msg)
lock obtained exclusive
>>> # Get lock in shared mode
>>> with sel.SELockShare(a_lock):
...     msg = 'lock obtained shared'
>>> print(msg)
lock obtained shared
Security Status Documentation Status

Installation

Windows:

pip install scottbrian-locking

Development setup

See tox.ini

Release History

  • 1.0.0
    • Initial release

  • 1.1.0
    • Add RELockObtain context manager

    • support python 3.11

  • 2.0.0
    • Add obtain_tf to context manager

    • Add allow_recursive_obtain

    • Delete setup.cfg

    • Make consistent log and error messages

    • Support python 3.12

    • Drop support for python < 3.12

  • 2.0.1
    • Fix documentation
      • change docs/source/index.rst

      • change docs/requirements.txt

      • change readthedoc.yml

  • 2.0.2
    • Fix verify_lock to refresh lock_info

    • Fix thread name in release granted log message

  • 2.1.0
    • Support python 3.13

  • 2.1.1
    • Support tox parallel

Meta

Scott Tuttle

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (<https://github.com/yourname/yourproject/fork>)

  2. Create your feature branch (git checkout -b feature/fooBar)

  3. Commit your changes (git commit -am ‘Add some fooBar’)

  4. Push to the branch (git push origin feature/fooBar)

  5. Create a new Pull Request

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

scottbrian_locking-2.1.1.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

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

scottbrian_locking-2.1.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file scottbrian_locking-2.1.1.tar.gz.

File metadata

  • Download URL: scottbrian_locking-2.1.1.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for scottbrian_locking-2.1.1.tar.gz
Algorithm Hash digest
SHA256 0c42ae4d8335ac0e275cfe5738eade891a519e76b9d5bde8af42c983e5de7280
MD5 8691e21be4d57427444c30df4d29c9b0
BLAKE2b-256 7883eaca4dadf2020a0e71b1257423d2ea8087d90fa02ec5ff86d6701dba006f

See more details on using hashes here.

File details

Details for the file scottbrian_locking-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scottbrian_locking-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 006710a13d9bde8b83767e3c86ddc226c17d994e5449c9c69c31f7d022f6390e
MD5 82301a51e23c08572ac93b27efa8ce11
BLAKE2b-256 fd1812d6a87c14d0db9efbcd1857bec0e9a7712f16846735197efac4e9b00d3b

See more details on using hashes here.

Supported by

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