+'''Make sure our atexit handler are called even on signals'''
+__author__ = 'Miki Tebeka <email@example.com>'
+from signal import signal, SIGTERM, SIGINT
+def signal_handler(signum, stackframe):
+ '''Just make sure we exit gracefully'''
+ for signum in (SIGTERM, SIGINT):
+ signal(signum, signal_handler)
+if __name__ == '__main__':
+ from os import kill, getpid
+ Cause suicide is painless
+ it brings on many changes
+ and I can take or leave it if I please.
+ ...and you can do the same thing if you please.
+ kill(getpid(), SIGTERM)