kubernetes-guide/codeblock/handle-sigterm/sigterm.py

13 lines
279 B
Python
Raw Normal View History

2023-11-08 20:29:30 +08:00
import signal, time, os
def shutdown(signum, frame):
print('Caught SIGTERM, shutting down')
# Finish any outstanding requests, then...
exit(0)
if __name__ == '__main__':
# Register handler
signal.signal(signal.SIGTERM, shutdown)
# Main logic goes here