fasteners
A python package that provides useful locks
What it is and what it does
Fasteners extends Python's standard threading locks to cover inter-process synchronization and reader-writer lock patterns. It provides InterProcessLock for exclusive file-based locking across processes (using fcntl on Unix and _locking on Windows), InterProcessReaderWriterLock for multi-reader/single-writer patterns across processes, and ReaderWriterLock for the same pattern within a single process. All locks expose a context-manager interface compatible with threading.Lock, making them drop-in replacements for simple use cases.
The package has been stable since its first release in 2015 and supports current Python versions (3.10 through 3.13, plus PyPy). It has no external runtime dependencies, making installation and deployment straightforward. The implementation trades some features (reentrancy, lock upgrading) for cross-platform compatibility, guaranteeing only the intersection of Unix fcntl and Windows file-locking semantics.
Use it for:
- Coordinate exclusive file access between multiple Python processes without a separate lock server.
- Implement reader-writer patterns where many processes read concurrently but writes must be exclusive.
- Protect shared resources in multi-threaded applications using the same API as standard threading.Lock.
- Ensure safe concurrent access to files or resources in cross-platform applications (Linux, macOS, Windows).
- Add process-level synchronization to existing code that already uses threading.Lock without major refactoring.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides cross-platform locks for synchronizing access between threads and processes, with both exclusive and reader-writer lock variants matching the threading.Lock API.
Yes. Fasteners is a stable, dependency-free solution for a common problem (cross-process locking) with no known vulnerabilities. The aging maintenance status is not a concern for a mature, narrowly-scoped library. Install it if you need inter-process locks or reader-writer patterns; the low friction and permissive license make it a safe choice.
Install
fasteners on PyPI
pip
pip install fastenersuv
uv add fastenerspoetry
poetry add fastenersInstalling fasteners
Before you install
Low friction—pure Python wheel with no runtime dependencies. Maintenance is aging (last release 368 days ago, last commit 2025-09-09), but the repository is active and not archived; suitable for stable, mature use cases where frequent updates are not expected.
License in practice
Apache-2.0 (permissive) allows commercial and private use with minimal restrictions; safe for most projects.
Quickstart
pip install fasteners
import fasteners
lock = fasteners.InterProcessLock('path/to/lock.file')
with lock:
pass # exclusive access
Verify before relying
- Whether ReaderWriterLock works correctly with eventlet or other non-standard threading implementations without custom thread identification functions.
- Performance characteristics under high contention or with many concurrent readers/writers.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 368 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 15,536,221/month — #1,181 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fasteners-0.20-py3-none-any.whl
Keywords: lock, thread, process, fasteners
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
locketLocket provides file-based locks for…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
readerwriterlockProvides reader-writer lock implementations for…
permissive · top 5,000 on PyPI
fastrlockA C-level re-entrant lock for CPython that…
permissive · top 5,000 on PyPI
lockfileProvides a platform-independent file locking…
permissive · top 1,000 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
aiorwlockProvides read-write locks for asyncio programs,…
permissive · top 5,000 on PyPI
zc.lockfileProvides portable inter-process locks…
unclear · top 5,000 on PyPI
fifolockFifolock provides a low-level building block…
permissive · top 15,000 on PyPI
gilknockerMeasures GIL contention within a specific code…
unclear · top 5,000 on PyPI