1#!/usr/bin/python
2
3from time import sleep
4import signal
5import sys
6
7
8def sigterm_handler(_signo, _stack_frame):
9 # Raises SystemExit(0):
10 sys.exit(0)
11
12if sys.argv[1] == "handle_signal":
13 signal.signal(signal.SIGTERM, sigterm_handler)
14
15try:
16 print "Hello"
17 i = 0
18 while True:
19 i += 1
20 print "Iteration #%i" % i
21 sleep(1)
22finally:
23 print "Goodbye"