Skip to main content

A combined process and thread lock

Project description

Combo Lock

The combo-lock is a combination of a process lock and a thread lock. Usable in cases both multiple threads and multiple processes are sharing the same resource such as a file in the file system.

The module utilizes the FileLock from filelock and the standard Lock from threading.

The FileLock uses a filesystem lock so the initialization of the class requires a path for the lock file.

Example

from combo_lock import ComboLock

lock = ComboLock('/tmp/my.lock')

with lock:
    write_my_shared_resource()

A NamedLock will save the lock file to shared memory using memory-tempfile

from combo_lock import NamedLock

lock = NamedLock('some_name')

with lock:
    write_my_shared_resource()

History

The combo-lock was originally created for Mycroft-core but as it's been useful in other projects a separate release seemed appropriate.

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

combo_lock-0.3.0.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file combo_lock-0.3.0.tar.gz.

File metadata

  • Download URL: combo_lock-0.3.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for combo_lock-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b04c5122272758985e966fee241d1a708630c7303b52026dad3389a1aa89719a
MD5 d72076ee7e0f79a662c413276cf71b7e
BLAKE2b-256 50bed02eca2cf9864e42faeff56bda6e6fc67d0669e0c6a0b164605b3c0bf3f6

See more details on using hashes here.

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