From 97154617f9cc4490065f1a6ece20779b734691f4 2011-04-08 00:38:08 From: MinRK Date: 2011-04-08 00:38:08 Subject: [PATCH] ipclusterz notices if controller fails to start --- diff --git a/IPython/zmq/parallel/ipcluster.py b/IPython/zmq/parallel/ipcluster.py index 150cba3..b458240 100644 --- a/IPython/zmq/parallel/ipcluster.py +++ b/IPython/zmq/parallel/ipcluster.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function import sys,os +import time from subprocess import Popen, PIPE from entry_point import parse_url @@ -52,7 +53,7 @@ def launch_process(mod, args): blackholew = file(os.devnull, 'w') blackholer = file(os.devnull, 'r') - proc = Popen(arguments, stdin=blackholer, stdout=blackholew, stderr=blackholew) + proc = Popen(arguments, stdin=blackholer, stdout=blackholew, stderr=PIPE) return proc def main(): @@ -67,6 +68,13 @@ def main(): '--transport','--loglevel','--packer'])+['--ident'] controller = launch_process('controller', controller_args) + for i in range(10): + time.sleep(.1) + if controller.poll() is not None: + print("Controller failed to launch:") + print (controller.stderr.read()) + sys.exit(255) + print("Launched Controller at %s"%args.url) engines = [ launch_process('engine', engine_args+['engine-%i'%i]) for i in range(args.n) ] print("%i Engines started"%args.n) @@ -76,9 +84,10 @@ def main(): p.wait() except KeyboardInterrupt: pass + wait_quietly(controller) map(wait_quietly, engines) - print ("Done") + print ("Engines cleaned up.") if __name__ == '__main__': main() \ No newline at end of file