Exemplo n.º 1
0
def tearDownModule():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    _kill(_pyomo_ns_process)
    _pyomo_ns_port = None
    _pyomo_ns_process = None
    _kill(_dispatch_srvr_process)
    _dispatch_srvr_port = None
    _dispatch_srvr_process = None
    [_kill(proc) for proc in _taskworker_processes]
    _taskworker_processes = []
    if os.path.exists(join(thisdir, "Pyro_NS_URI")):
        try:
            os.remove(join(thisdir, "Pyro_NS_URI"))
        except OSError:
            pass
Exemplo n.º 2
0
 def _run_cmd_with_pyro(self, cmd, num_servers):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         class_name, test_name = self.id().split('.')[-2:]
         for i in range(num_servers):
             outname = os.path.join(thisdir,
                                    class_name+"."+test_name+".scenariotreeserver_"+str(i+1)+".out")
             self._tempfiles.append(outname)
             with open(outname, "w") as f:
                 scenariotreeserver_processes.append(
                     subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                      ["--pyro-host="+str(ns_host)] + \
                                      ["--pyro-port="+str(ns_port)],
                                      stdout=f,
                                      stderr=subprocess.STDOUT))
         cmd.append("--scenario-tree-manager=pyro")
         cmd.append("--pyro-host="+str(ns_host))
         cmd.append("--pyro-port="+str(ns_port))
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         self._run_cmd(cmd)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisdir,'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisdir,'Pyro_NS_URI'))
             except OSError:
                 pass
Exemplo n.º 3
0
 def test_solve_distributed(self):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         class_name, test_name = self.id().split('.')[-2:]
         for i in range(3):
             outname = os.path.join(thisdir,
                                    class_name+"."+test_name+".scenariotreeserver_"+str(i+1)+".out")
             self._tempfiles.append(outname)
             with open(outname, "w") as f:
                 scenariotreeserver_processes.append(
                     subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                      ["--pyro-host="+str(ns_host)] + \
                                      ["--pyro-port="+str(ns_port)],
                                      stdout=f,
                                      stderr=subprocess.STDOUT))
         cmd = [sys.executable, join(examples_dir, 'solve_distributed.py'), str(ns_port)]
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         self._run_cmd(cmd)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisdir,'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisdir,'Pyro_NS_URI'))
             except OSError:
                 pass
     self._cleanup()
Exemplo n.º 4
0
def tearDownModule():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    _kill(_pyomo_ns_process)
    _pyomo_ns_port = None
    _pyomo_ns_process = None
    _kill(_dispatch_srvr_process)
    _dispatch_srvr_port = None
    _dispatch_srvr_process = None
    for i, proc in enumerate(_taskworker_processes):
        _kill(proc)
        outname = os.path.join(thisdir,
                               "TestCapture_scenariotreeserver_" + \
                               str(i+1) + ".out")
        if os.path.exists(outname):
            try:
                os.remove(outname)
            except OSError:
                pass
    _taskworker_processes = []
    if os.path.exists(os.path.join(thisdir, "Pyro_NS_URI")):
        try:
            os.remove(os.path.join(thisdir, "Pyro_NS_URI"))
        except OSError:
            pass