Skip to main content

Library to enable your code run as a daemon process on Unix-like systems.

Project description

Latest version Travis CI PyPI montly downloads PyPI last version available PyPI license

daemonize is a library for writing system daemons in Python. It is distributed under MIT license. Latest version can be downloaded from PyPI. Full documentation can be found at ReadTheDocs.

Dependencies

It is tested under following Python versions:

  • 2.6

  • 2.7

  • 3.3

  • 3.4

  • 3.5

Installation

You can install it from Python Package Index (PyPI):

$ pip install daemonize

Usage

from time import sleep
from daemonize import Daemonize

pid = "/tmp/test.pid"


def main():
    while True:
        sleep(5)

daemon = Daemonize(app="test_app", pid=pid, action=main)
daemon.start()

File descriptors

Daemonize object’s constructor understands the optional argument keep_fds which contains a list of FDs which should not be closed. For example:

import logging
from daemonize import Daemonize

pid = "/tmp/test.pid"
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.propagate = False
fh = logging.FileHandler("/tmp/test.log", "w")
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)
keep_fds = [fh.stream.fileno()]


def main():
    logger.debug("Test")

daemon = Daemonize(app="test_app", pid=pid, action=main, keep_fds=keep_fds)
daemon.start()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daemonize-2.4.3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

daemonize-2.4.3-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file daemonize-2.4.3.tar.gz.

File metadata

  • Download URL: daemonize-2.4.3.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for daemonize-2.4.3.tar.gz
Algorithm Hash digest
SHA256 9a51875ee23606ee303fce54b9ff798ff7db853b2980b4eacf224b9155c6b390
MD5 33463740073873d43bad3ad4be143f1f
BLAKE2b-256 ad1f87ca71db1e8e964eb827fe800f6387726c8c4e377293be9977666ad8fdfe

See more details on using hashes here.

File details

Details for the file daemonize-2.4.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for daemonize-2.4.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1becb7d8eba4af43bf6e9a719f60653913918009f2dae2c0c2ab7f5b15dce007
MD5 bb51c3b031bdd9268361abd03f93a70b
BLAKE2b-256 2d3e68735ee5f1ba8d382aba06c7fa55db3731bc0d69742d388156bcf1ac6e3f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page