skillfed

fasteners

A python package that provides useful locks

fasteners v0.20 15.5M downloads/30d#1,181 on PyPI280
Permissive license Apache-2.0 AGING released

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 fasteners

uv

uv add fasteners

poetry

poetry add fasteners

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: Implementation :: PyPyTopic :: Utilities

Tags

process lockinginter-process lockreader writer lockthread synchronizationcross-platform locksfile-based lockingconcurrent access control
concurrencysynchronizationipc

More Utilities packages