Skip to content

module for process SIGTERM and SIGINT signals gracefully

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.TXT
Notifications You must be signed in to change notification settings

Sukhavati-Labs/graceful_killer

 
 

Repository files navigation

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:

About

module for process SIGTERM and SIGINT signals gracefully

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.TXT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%