def _get_test_nameserver(ns_host="127.0.0.1", num_tries=20): if not (using_pyro3 or using_pyro4): return None, None ns_options = None if using_pyro3: ns_options = ["-r", "-k", "-n " + ns_host] elif using_pyro4: ns_options = ["--host=" + ns_host] # don't start the broadcast server ns_options += ["-x"] ns_port = None ns_process = None for i in range(num_tries): try: ns_port = find_unused_port() print("Trying nameserver with port: " + str(ns_port)) cmd = ["pyomo_ns"] + ns_options if using_pyro3: cmd += ["-p " + str(ns_port)] elif using_pyro4: cmd += ["--port=" + str(ns_port)] print(' '.join(cmd)) ns_process = \ subprocess.Popen(cmd, stdout=subprocess.PIPE) time.sleep(5) _poll(ns_process) break except OSError: print(sys.exc_info()) print("Failed to find open port - trying again in 20 seconds") time.sleep(20) _kill(ns_process) ns_port = None ns_process = None return ns_process, ns_port
def _get_test_dispatcher(ns_host=None, ns_port=None, dispatcher_host="127.0.0.1", num_tries=20): if not (using_pyro3 or using_pyro4): return None, None dispatcher_port = None dispatcher_process = None for i in range(num_tries): try: dispatcher_port = find_unused_port() print("Trying dispatcher with port: " +str(dispatcher_port)) dispatcher_process = \ subprocess.Popen(["dispatch_srvr"] + \ ["--host="+str(ns_host)] + \ ["--port="+str(ns_port)] + \ ["--daemon-host="+str(dispatcher_host)] + \ ["--daemon-port="+str(dispatcher_port)], stdout=subprocess.PIPE) time.sleep(5) _poll(dispatcher_process) break except OSError as e: print(sys.exc_info()) print("Failed to find open port - trying again in 20 seconds") time.sleep(20) _kill(dispatcher_process) dispatcher_port = None dispatcher_process = None return dispatcher_process, dispatcher_port
def _get_test_nameserver(ns_host="127.0.0.1", num_tries=20): if not (using_pyro3 or using_pyro4): return None, None ns_options = None if using_pyro3: ns_options = ["-r","-k","-n "+ns_host] elif using_pyro4: ns_options = ["--host="+ns_host] ns_port = None ns_process = None for i in range(num_tries): try: ns_port = find_unused_port() print("Trying nameserver with port: " +str(ns_port)) cmd = ["pyomo_ns"] + ns_options if using_pyro3: cmd += ["-p "+str(ns_port)] elif using_pyro4: cmd += ["--port="+str(ns_port)] print(' '.join(cmd)) ns_process = \ subprocess.Popen(cmd) time.sleep(5) _poll(ns_process) break except OSError: print(sys.exc_info()) print("Failed to find open port - trying again in 20 seconds") time.sleep(20) _kill(ns_process) ns_port = None return ns_process, ns_port