Daemon application help functions.
Project description
Daemon application help functions.
Install
pip install daemon-application
Usage
import time import threading import signal from daemon_application import daemon_start stopflag = False def main(): def on_exit(*args, **kwargs): with open("backgroud.log", "a", encoding="utf-8") as fobj: print("process got exit signal...", file=fobj) print(args, file=fobj) print(kwargs, file=fobj) global stopflag stopflag = True signal.signal(signal.SIGTERM, on_exit) signal.signal(signal.SIGINT, on_exit) while not stopflag: time.sleep(1) print(time.time()) if __name__ == "__main__": print("start background application...") daemon_start(main, "background.pid", True)
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 daemon-application-0.2.1.tar.gz
.
File metadata
- Download URL: daemon-application-0.2.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 452a19d691da8cc47e6decd2b2e845244584a7a88aa877037d05c28cd45dcb2e |
|
MD5 | 104bd543381e940afd8ca57522876abc |
|
BLAKE2b-256 | 80dddf6d13038805b28c352ab74c054f332c1063515c1f281881e584235cc016 |