pid
Pidfile featuring stale detection and file-locking, can also be used as context-manager or decorator
What it is and what it does
pid is a lightweight library for creating and managing Unix-style process ID files. It wraps pidfile creation with stale detection (identifying leftover files from crashed processes), fcntl-based file locking to prevent concurrent execution, and permission control via chmod and chown. The package depends only on psutil.
It supports three usage patterns: as a context manager (recommended for clean resource handling), as a decorator on functions, or integrated with daemon frameworks. The library handles signal cleanup via atexit and is designed to work with daemonization workflows. However, the project has been abandoned since its last release on 2020-07-18, so it receives no maintenance or updates.
Use it for:
- Enforce single-instance execution of a long-running service or batch job by locking a pidfile on startup
- Detect and clean up stale pidfiles left behind after a process crash, preventing false 'already running' errors
- Integrate pidfile management into a daemon context manager to coordinate process lifecycle with logging and signal handling
- Decorate a main function to automatically acquire and release a pidfile without explicit context manager syntax
- Manage process identity across fork operations in daemon scenarios where PID determination must happen at lock time
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Manages process ID files with stale detection, file locking, and permission control, available as a context manager or decorator for daemon and single-instance enforcement.
Yes, if you need pidfile management for a daemon or single-instance application and can tolerate an unmaintained package. The code is stable and has no known vulnerabilities, but expect no fixes for compatibility issues or edge cases. For new projects, consider whether a more actively maintained alternative exists; for existing code already using pid, there is no urgent reason to migrate.
Install
pid on PyPI
pip
pip install piduv
uv add pidpoetry
poetry add pidInstalling pid
Before you install
Low install friction; pure Python wheel. Maintenance is abandoned—last release was 2020-07-18, so expect no updates for bugs or Python version changes, though the package is marked Production/Stable and has no known vulnerabilities.
License in practice
Licensed under Apache Software License (permissive), so you can use, modify, and distribute freely with minimal restrictions.
Quickstart
from pid import PidFile
with PidFile('myapp') as p:
print(p.pidname) # 'myapp'
# Your application code here
# PidFile cleaned up automatically on exit
Verify before relying
- Whether the package works reliably with modern Python versions given no updates since 2020
- Whether fcntl-based locking behaves as expected on non-POSIX systems or in containerized environments
- Compatibility with Python versions beyond 3.8 listed in classifiers
Package facts
| License | ASL (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — psutil |
| Maintenance | abandoned — 2,218 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 191,560/month — #9,881 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pid-3.0.4-py2.py3-none-any.whl
Keywords: pid, pidfile, context, manager, decorator
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
dumb-initdumb-init is a minimal init system that runs as…
unclear · top 15,000 on PyPI
python-daemonImplements PEP 3143 well-behaved Unix daemon…
permissive · top 5,000 on PyPI
zc.lockfileProvides portable inter-process locks…
unclear · top 5,000 on PyPI
simple-pidA dependency-free PID controller library that…
permissive · top 15,000 on PyPI
daemonizeDaemonize provides a Python library for…
permissive · top 15,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
flufl.lockProvides NFS-safe file locking with timeout…
permissive · top 5,000 on PyPI
redlock-pyImplements Redis-based distributed locks using…
permissive · top 15,000 on PyPI
systemd-pythonProvides Python bindings to systemd's native C…
copyleft · top 5,000 on PyPI