skillfed

pid

Pidfile featuring stale detection and file-locking, can also be used as context-manager or decorator

pid v3.0.4 191.6K downloads/30d#9,881 on PyPI105
Permissive license ASL Abandoned released

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 pid

uv

uv add pid

poetry

poetry add pid

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: PyPy

Tags

pidfile managementprocess id file lockingdaemon pidfile context managerstale pid detectionsingle instance enforcementpidfile decoratorfcntl-based pid locking
daemon-lifecycleprocess-locking

More Monitoring packages