From a587975a99373e0c1c79940e95fc9d9104f41380 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 16 Oct 2011 01:05:47 +0200 Subject: [PATCH] catch keyboardirq in parallel mode, so it's not raised into multiprocess Signed-off-by: Nico Schottelius --- bin/cdist | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/cdist b/bin/cdist index 9786960c..c00bb73a 100755 --- a/bin/cdist +++ b/bin/cdist @@ -125,10 +125,10 @@ def configinstall(args, mode): for host in args.host: if args.parallel: log.debug("Creating child process for %s", host) - process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode)) + process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode, True)) process[host].start() else: - if not configinstall_onehost(host, args, mode): + if not configinstall_onehost(host, args, mode, parallel=False): failed_hosts.append(host) if args.parallel: @@ -157,7 +157,7 @@ def configinstall(args, mode): sys.exit(0) -def configinstall_onehost(host, args, mode): +def configinstall_onehost(host, args, mode, parallel): """Configure or install ONE remote system""" try: @@ -177,6 +177,10 @@ def configinstall_onehost(host, args, mode): except cdist.Error as e: log.error(e) return False + except KeyboardInterrupt: + # Do not care in sequential mode, catch in parallel mode + if not parallel: + raise return True