locks
POSIX file system locking using flock.
Getting started
Install this package with
pip install locks
Usage
The simplest usage is to block indefinitely until the lock is acquired
from locks import Mutex
with Mutex('/tmp/file.lock'):
# do exclusive stuff here
Alternatively, block until a timeout is reached
from locks import Mutex
try:
with Mutex('/tmp/file.lock', timeout=0.5):
# do exclusive stuff here
except BlockingIOError:
# handle the failure to acquire the lock
Finally, a common paradigm is to attempt to acquire the lock without blocking,
do something, and then block indefinitely. Here callback will be called once
if we cannot immediately acquire the lock, and then we will block indefinitely.
def callback():
print("Blocking: waiting for file lock on '/tmp/file.lock'")
with Mutex('/tmp/file.lock', callback=callback):
# do exclusive stuff here
If both callback and timeout are used then we will attempt to
acquire the lock until the timeout is reached, and then we will block
indefinitely.
License
This project is licensed under the MIT License. See the LICENSE file.
Metadata
Release files for locks 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| locks-0.1.1.tar.gz | 3.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| locks-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 7.3 kB
Release files / locks-0.1.1.tar.gz
| Download URL | locks-0.1.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a894bcd725bb0d36613d1ccb4880d2c9c967ad8107619fad4c6a609dd70a3df0
|
|
BLAKE2b-256 checksum How to use checksums |
297c94a8e0b91c0b9cec5adf7cd7dc871b215835ca1ba9e3f595fee8a0fb9e49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3
|
Release files / locks-0.1.1-py2.py3-none-any.whl
| Download URL | locks-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b8053d71dc96394639ecb4358c872f186ae7a3b70b759bb00d4966dda8e208ae
|
|
BLAKE2b-256 checksum How to use checksums |
6e9ad82c0c43c1d89da8ef35a50f3266ebf4d69aaf00d94202000969c7040943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3
|
Security for locks 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.