BAPSicle/helpers/the_terminator.py
2021-04-17 22:51:43 +01:00

14 lines
375 B
Python

# Based on https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully
import signal
class Terminator:
terminate = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self, signum, frame):
self.terminate = True