From 68426271f0bf742c5848ab5f08119d38ed282977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Wed, 15 Feb 2017 18:27:33 +0100 Subject: [PATCH] SIGINT signals are now handled nicely instead of crashing --- coub-dl.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coub-dl.py b/coub-dl.py index 2f4b821..d98d894 100644 --- a/coub-dl.py +++ b/coub-dl.py @@ -15,6 +15,7 @@ from argparse import ArgumentParser from functools import wraps from tempfile import mkdtemp from shutil import rmtree +from signal import signal, SIGINT @@ -230,8 +231,15 @@ class temporary_directory: rmtree(self.name) +@call_verbose(before_message='\nExiting!\n', after_message='') +def sigint_handler(signal, frame): + exit() + + if __name__ == '__main__': + signal(SIGINT, sigint_handler) + args = parse_cmd_arguments() VERBOSE = False if args.nonverbose else True