locket
File-based locks for Python on Linux and Windows
Decision gist · record as of 2026-08-14
Yes, for simple inter-process locking on a single machine. The package is stable, has no known vulnerabilities, and carries minimal install friction. However, be aware that it is no longer maintained—if you need active development, bug fixes, or support for future Python versions, consider whether a maintained alternative better suits your long-term needs. Not suitable for distributed locking across multiple machines.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Behaviour after fork() is undefined; use with caution in multi-process contexts involving forking.
- Low install friction with no runtime dependencies.
- Maintenance is stalled—last release was in 2022 and the repository shows no activity since February 2023, though it remains unarchived and the package is widely downloaded (top 1000 on PyPI).
License · maintenance · safety
BSD-2-Clause (permissive) — BSD-2-Clause is permissive; you may use, modify, and distribute locket freely in commercial and private projects with minimal restrictions.
last release 2022-04-20 (1577 days) · last repo commit 2023-02-03 · 26 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 22,539,665 downloads/mo, #968 on PyPI
Alternatives
Verify before relying
import locket
with locket.lock_file("path/to/lock/file"):
perform_action()
# Or with timeout:
with locket.lock_file("path/to/lock/file", timeout=30):
perform_action()- Whether the package is actively maintained or has a successor; last commit was 2023-02-03.
- Whether there are known compatibility issues with recent Python versions beyond those listed in classifiers.
What it is and what it does
Locket is a file-based locking library that enables multiple processes to safely coordinate access to shared resources by acquiring and releasing locks tied to a filesystem path. It mimics the behavior of threading.Lock from the standard library but works across process boundaries, making it useful for inter-process synchronization on both Linux and Windows.
The package is lightweight with zero runtime dependencies and supports a wide range of Python versions from 2.7 through 3.10. Locks can be acquired with optional timeouts, and the library provides both context-manager and explicit acquire/release interfaces. However, the project is no longer actively maintained—the last release was in April 2022 and the repository has seen no commits since February 2023.
Use it for
- Coordinate file access between independent Python processes that need to read or write the same file without corruption.
- Implement a simple distributed lock for batch jobs or scheduled tasks running on the same machine.
- Prevent multiple instances of a daemon or service from running simultaneously by using a lock file.
- Serialize access to a shared resource (database, cache, or configuration) across multiple worker processes.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, for simple inter-process locking on a single machine.
The package is stable, has no known vulnerabilities, and carries minimal install friction. However, be aware that it is no longer maintained—if you need active development, bug fixes, or support for future Python versions, consider whether a maintained alternative better suits your long-term needs. Not suitable for distributed locking across multiple machines.
Install
locket on PyPI
Before you install
Low install friction with no runtime dependencies. Maintenance is stalled—last release was in 2022 and the repository shows no activity since February 2023, though it remains unarchived and the package is widely downloaded (top 1000 on PyPI).
Behaviour after fork() is undefined; use with caution in multi-process contexts involving forking.
License in practice
BSD-2-Clause is permissive; you may use, modify, and distribute locket freely in commercial and private projects with minimal restrictions.
Quickstart
import locket
with locket.lock_file("path/to/lock/file"):
perform_action()
# Or with timeout:
with locket.lock_file("path/to/lock/file", timeout=30):
perform_action()
Verify before relying
- Whether the package is actively maintained or has a successor; last commit was 2023-02-03.
- Whether there are known compatibility issues with recent Python versions beyond those listed in classifiers.
Package facts
| License | BSD-2-Clause permissive |
| Python support | Supports the current Python release >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 1,577 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 22,539,665 / month, #968 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: locket-1.0.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “file-based locks python”
- locketLocket provides file-based locks for inter-process synchronization on…
- fastenersProvides cross-platform locks for synchronizing access between…
- oslo.concurrencyoslo.concurrency provides locking mechanisms and external process…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Provides cross-platform locks for synchronizing access between threads and processes, with both exclusive and reader-writer lock variants matching the threading.Lock API.
Install it if you need inter-process locks or reader-writer patterns; the low friction and permissive license make it a safe choice.
Copy files locked by other processes on Windows by leveraging the Volume Shadow Copy Service, requiring admin access to create and delete shadow copies.
Provides portable inter-process locks implemented using lock files and OS-level file-locking primitives, allowing multiple processes to coordinate access to shared resources.
Portalocker provides cross-platform file locking with support for exclusive and shared locks, plus Redis-based distributed locks and process-aware PID file locking.
Install it if you need file or process coordination; the optional extras (pywin32, redis) are only required for specific lock types.
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
Provides read-write locks for asyncio programs, allowing multiple concurrent readers or a single exclusive writer to synchronize access to shared data.
Install it if you have asyncio code where read-write contention patterns would benefit from allowing concurrent readers; otherwise a simple asyncio.Lock is sufficient.
See also atomic_dict · lockfile · flufl.lock · PyMySQLLock