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
Release history Release notifications | RSS feed
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 hashes)