skillfed

python-daemon

Library to implement a well-behaved Unix daemon process.

python-daemon v3.1.2 21.1M downloads/30d#1,011 on PyPI
Permissive license Copying this work ################# ‘python-daemon’ is under Copyright © 2008–2024 Ben Finney and others. This work, ‘python-daemon’, is free software: you may copy, modify, and/or distribute this… (full text in the JSON record) DORMANT released

What it is and what it does

python-daemon is a library that implements the PEP 3143 standard for well-behaved Unix daemon processes. Creating a daemon—a process that runs in the background detached from the terminal—requires several tricky steps: forking, closing file descriptors, handling signals, and setting up the process environment correctly. This library encapsulates all of that complexity into a simple context manager interface, so you can wrap your main program logic and let DaemonContext handle the daemon setup automatically.

You configure the daemon by setting options on a DaemonContext instance (signal handlers, working directory, file descriptors to preserve, etc.) and then use it as a context manager. The library depends only on lockfile for file-based locking during the daemonization process. It requires Python 3.7 or later and runs only on POSIX systems.

Use it for:

  • Long-running background services (log aggregators, monitoring agents, scheduled job runners) that need to detach from the terminal.
  • System utilities that must fork and run as true Unix daemons with proper signal handling and file descriptor management.
  • Applications that need to customize daemon behavior (e.g., preserve specific file descriptors, set working directory, manage pidfiles).

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Implements PEP 3143 well-behaved Unix daemon processes, handling the complex steps of forking and process environment setup so your program can run reliably in the background.

Yes, if you are building a Unix daemon in Python and want to follow PEP 3143 correctly without reimplementing the forking and setup logic yourself. The dormant maintenance status is not a blocker—the package is feature-complete and stable—but verify that it meets your Python version and OS requirements. Not suitable for Windows.

Install

python-daemon on PyPI

pip

pip install python-daemon

uv

uv add python-daemon

poetry

poetry add python-daemon

Installing python-daemon

Before you install

Low install friction with a single lightweight dependency (lockfile). Maintenance is dormant—last release was 619 days ago—but the package is marked Production/Stable and has been actively maintained since 2009, suggesting it is feature-complete and unlikely to require frequent updates.

License in practice

Dual-licensed under Apache License 2.0 (daemon library) and GNU General Public License version 3+ (packaging and tests). Permissive treatment means you can use, modify, and distribute freely, but be aware of the GPL v3 component if you redistribute the package itself.

Quickstart

pip install python-daemon

import daemon

with daemon.DaemonContext():
    # Your background process code here
    pass

Unix/POSIX systems only; not supported on Windows.

Verify before relying

  • Whether dormant maintenance status (last release 619 days ago) poses a risk for future Python or OS compatibility.
  • Specific behavior differences or limitations when used with modern async frameworks or process managers.

Package facts

License Copying this work ################# ‘python-daemon’ is under Copyright © 2008–2024 Ben Finney and others. This work, ‘python-daemon’, is free software: you may copy, modify, and/or distribute this… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 1 — lockfile
Maintenance dormant — 619 days since the last release
First released
Downloads 21,136,028/month — #1,011 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_daemon-3.1.2-py3-none-any.whl

Keywords: daemon, fork, unix

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: POSIXProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules

Tags

unix daemon process librarybackground process managementPEP 3143 daemonfork and daemonizewell-behaved daemonpython daemon context manager
unix-daemonbackground-processposix-only

More Python Modules packages