From 7440bd4222d81bab8dd46e274c86db71ab12cd30 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sat, 9 May 2015 13:20:56 +0200 Subject: [PATCH] Do a proper close on SIGINT and SIGTERM --- nemubot/__main__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nemubot/__main__.py b/nemubot/__main__.py index 259096b..4f739f8 100644 --- a/nemubot/__main__.py +++ b/nemubot/__main__.py @@ -16,6 +16,7 @@ def main(): import os + import signal import sys # Parse command line arguments @@ -153,6 +154,12 @@ def main(): for module in args.module: __import__(module) + # Signals handling + def sighandler(signum, frame): + context.quit() + signal.signal(signal.SIGINT, sighandler) + signal.signal(signal.SIGTERM, sighandler) + context.start() context.join()