module for process SIGTERM, SIGHUP and SIGINT signals gracefully
Project description
GracefulKiller
GracefulKiller python3 module for process SIGTERM, SIGHUP and SIGINT signals gracefully
Requirements
- signal (build-in)
Details
Preparations
Install GracefulKiller using pip:
pip install [--user] gracefulkiller
Usage
Import module:
from GracefulKiller import GracefulKiller
Example 1
# import module
from GracefulKiller import GracefulKiller
# create killer
killer = GracefulKiller()
# create while loop using killer, will exit from loop if SIGTERM or SIGINT received
while not killer.kill_now:
# do stuff
Example 2
# import module
from GracefulKiller import GracefulKiller
# create killer
killer = GracefulKiller()
# use it as check for SIGTERM and SIGINT
if killer.kill_now:
sys.exit()
Example 3
# import module
from GracefulKiller import GracefulKiller, Loop
# shutdown handler
def shutdown_handler():
print("shutdown")
# create killer with shutdown handler
killer = GracefulKiller(shutdown_handler)
# start killer loop
Loop(killer, 1).start()
Maintainers
Special thanks to:
- williams824 Pull request #1: There is no SIGHUP signal under windows
- cuihairu Pull request #3: a simple loop
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
GracefulKiller-0.4.6.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for GracefulKiller-0.4.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09724ddb217b951d42a3cecdc0daf762870fe8599903b35cdbe1a44f11bf2465 |
|
MD5 | 3e072d77d49d6fbb460918abafaa5779 |
|
BLAKE2b-256 | 44b4242db840ec6461ce95ad60eeaa6f9f277f069f119ec91b2c757bb6e832e8 |