From 58a88ca5bd5dacad2860abeeca60ea24555e1e0b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 7 Mar 2012 11:50:16 +0100 Subject: [PATCH] remove useless try: block that was needed to find out how multiprocess /sigint behaviour works NOT needed: KeyBoardInterrupet (aka SIGINT) is forwarded to processes spawned by multiprocess! Signed-off-by: Nico Schottelius --- bin/cdist | 59 ++++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/bin/cdist b/bin/cdist index 9c15a8cf..97dd4107 100755 --- a/bin/cdist +++ b/bin/cdist @@ -115,48 +115,35 @@ def configinstall(args, mode): import atexit atexit.register(lambda: os.remove(initial_manifest_temp_path)) - try: - process = {} - failed_hosts = [] - time_start = time.time() - - 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, True)) - process[host].start() - else: - if not configinstall_onehost(host, args, mode, parallel=False): - failed_hosts.append(host) + process = {} + failed_hosts = [] + time_start = time.time() + for host in args.host: if args.parallel: - for p in process.keys(): - log.debug("Joining process %s", p) - process[p].join() + log.debug("Creating child process for %s", host) + process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode, True)) + process[host].start() + else: + if not configinstall_onehost(host, args, mode, parallel=False): + failed_hosts.append(host) - if not process[p].exitcode == 0: - failed_hosts.append(p) + if args.parallel: + for p in process.keys(): + log.debug("Joining process %s", p) + process[p].join() - if len(failed_hosts) > 0: - log.warn("Failed to deploy to the following hosts: " + - " ".join(failed_hosts)) - exit_code = 1 + if not process[p].exitcode == 0: + failed_hosts.append(p) - time_end = time.time() - log.info("Total processing time for %s host(s): %s", len(args.host), - (time_end - time_start)) + if len(failed_hosts) > 0: + log.warn("Failed to deploy to the following hosts: " + + " ".join(failed_hosts)) + exit_code = 1 - except KeyboardInterrupt: - if args.parallel: - for p in process.keys(): - # NOT needed: KeyBoardInterrupet (aka SIGINT) - # is forwarded to processes spawned by multiprocess! - # pid = process[p].pid.__str__() - #log.warn("Terminating deploy " + p + " (" + pid + ")") - # process[p].terminate() - pass - - sys.exit(0) + time_end = time.time() + log.info("Total processing time for %s host(s): %s", len(args.host), + (time_end - time_start)) def configinstall_onehost(host, args, mode, parallel):