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 <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-03-07 11:50:16 +01:00
parent 531ad2966f
commit 58a88ca5bd

View file

@ -115,48 +115,35 @@ def configinstall(args, mode):
import atexit import atexit
atexit.register(lambda: os.remove(initial_manifest_temp_path)) atexit.register(lambda: os.remove(initial_manifest_temp_path))
try: process = {}
process = {} failed_hosts = []
failed_hosts = [] time_start = time.time()
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)
for host in args.host:
if args.parallel: if args.parallel:
for p in process.keys(): log.debug("Creating child process for %s", host)
log.debug("Joining process %s", p) process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode, True))
process[p].join() process[host].start()
else:
if not configinstall_onehost(host, args, mode, parallel=False):
failed_hosts.append(host)
if not process[p].exitcode == 0: if args.parallel:
failed_hosts.append(p) for p in process.keys():
log.debug("Joining process %s", p)
process[p].join()
if len(failed_hosts) > 0: if not process[p].exitcode == 0:
log.warn("Failed to deploy to the following hosts: " + failed_hosts.append(p)
" ".join(failed_hosts))
exit_code = 1
time_end = time.time() if len(failed_hosts) > 0:
log.info("Total processing time for %s host(s): %s", len(args.host), log.warn("Failed to deploy to the following hosts: " +
(time_end - time_start)) " ".join(failed_hosts))
exit_code = 1
except KeyboardInterrupt: time_end = time.time()
if args.parallel: log.info("Total processing time for %s host(s): %s", len(args.host),
for p in process.keys(): (time_end - time_start))
# 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)
def configinstall_onehost(host, args, mode, parallel): def configinstall_onehost(host, args, mode, parallel):