Skip to main content

flufl.lock

NFS-safe file locking with timeouts for POSIX and Windows.

The flufl.lock library provides an NFS-safe file-based locking algorithm influenced by the GNU/Linux open(2) manpage, under the description of the O_EXCL option.

[…] O_EXCL is broken on NFS file systems, programs which rely on it for performing locking tasks will contain a race condition. The solution for performing atomic file locking using a lockfile is to create a unique file on the same fs (e.g., incorporating hostname and pid), use link(2) to make a link to the lockfile. If link() returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

The assumption made here is that there will be no outside interference, e.g. no agent external to this code will ever link() to the specific lock files used.

Lock objects support lock-breaking so that you can’t wedge a process forever. This is especially helpful in a web environment, but may not be appropriate for all applications.

Locks have a lifetime, which is the maximum length of time the process expects to retain the lock. It is important to pick a good number here because other processes will not break an existing lock until the expected lifetime has expired. Too long and other processes will hang; too short and you’ll end up trampling on existing process locks – and possibly corrupting data. In a distributed (NFS) environment, you also need to make sure that your clocks are properly synchronized.

Author

flufl.lock is Copyright (C) 2007-2022 Barry Warsaw <barry@python.org>

Licensed under the terms of the Apache License Version 2.0. See the LICENSE file for details.

Project details

Metadata

Release files for flufl.lock 7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flufl.lock 7.0
File Size Uploaded Provenance Actions
flufl.lock-7.0.tar.gz 33.2 kB Without provenance Details for flufl.lock-7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flufl.lock 7.0
File Interpreter ABI Platform Actions
flufl.lock-7.0-py3-none-any.whl Python 3 none any Details for flufl.lock-7.0-py3-none-any.whl

Total release size: 44.3 kB

Release files / flufl.lock-7.0.tar.gz

Download URL flufl.lock-7.0.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1415f7d19d8dd96a58242e0efb90ce3cb1877fb545074ad8c1cae4cb7191fe01
BLAKE2b-256 checksum
How to use checksums
52787dedbee8bf42c22d10e0198eca82e3681e2aabc02efa52833702d66440a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / flufl.lock-7.0-py3-none-any.whl

Download URL flufl.lock-7.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4731a98cf881cefc40c418f961f0238124e984f7c0f8d2db30afb017fbd26e05
BLAKE2b-256 checksum
How to use checksums
e3270a97686059f9723aee71460944df82f38cdf12d9c2f0e8855ea25f70bd1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Security for flufl.lock 7.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

7.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page