Library to enable your code run as a daemon process on Unix-like systems.
Project description
# daemonize [![Build Status](https://secure.travis-ci.org/thesharp/daemonize.png)](http://travis-ci.org/thesharp/daemonize)
## Description daemonize is a library for writing system daemons in Python. It has some bits from [daemonize.sourceforge.net](http://daemonize.sourceforge.net). It is distributed under MIT license.
## Dependencies It is tested under following Python versions:
2.6
2.7
3.3
## 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file daemonize-2.2.tar.gz
.
File metadata
- Download URL: daemonize-2.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d42b1e9d45449fb134b64cfbf9fa812f2579df6f9e963e158f6f9bd6a1fd3d8 |
|
MD5 | b4e07bdc58a39e9dfee70c5879a22072 |
|
BLAKE2b-256 | 822b5bd6a9be1da6cfb1b2c6c6bd54a656ef040970f48e82642c2e41c9705154 |