catch keyboardirq in parallel mode, so it's not raised into multiprocess

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-16 01:05:47 +02:00
parent 7b770b7b35
commit a587975a99

View file

@ -125,10 +125,10 @@ def configinstall(args, mode):
for host in args.host: for host in args.host:
if args.parallel: if args.parallel:
log.debug("Creating child process for %s", host) 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() process[host].start()
else: else:
if not configinstall_onehost(host, args, mode): if not configinstall_onehost(host, args, mode, parallel=False):
failed_hosts.append(host) failed_hosts.append(host)
if args.parallel: if args.parallel:
@ -157,7 +157,7 @@ def configinstall(args, mode):
sys.exit(0) sys.exit(0)
def configinstall_onehost(host, args, mode): def configinstall_onehost(host, args, mode, parallel):
"""Configure or install ONE remote system""" """Configure or install ONE remote system"""
try: try:
@ -177,6 +177,10 @@ def configinstall_onehost(host, args, mode):
except cdist.Error as e: except cdist.Error as e:
log.error(e) log.error(e)
return False return False
except KeyboardInterrupt:
# Do not care in sequential mode, catch in parallel mode
if not parallel:
raise
return True return True