From 3ecab04f195b785ed6e9c5e89ec6195e5043c910 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 80ae7f9..8fa2b51 100644 --- a/nemubot/__main__.py +++ b/nemubot/__main__.py @@ -18,6 +18,7 @@ def main(): import os + import signal import sys # Parse command line arguments @@ -155,6 +156,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()