def add_engines(n=1, profile='iptest', total=False):
    """add a number of engines to a given profile.
    
    If total is True, then already running engines are counted, and only
    the additional engines necessary (if any) are started.
    """
    rc = Client(profile=profile)
    base = len(rc)
    
    if total:
        n = max(n - base, 0)
    
    eps = []
    for i in range(n):
        ep = TestProcessLauncher()
        ep.cmd_and_args = ipengine_cmd_argv + [
            '--profile=%s' % profile,
            '--log-level=50',
            '--InteractiveShell.colors=nocolor'
            ]
        ep.start()
        launchers.append(ep)
        eps.append(ep)
    tic = time.time()
    while len(rc) < base+n:
        if any([ ep.poll() is not None for ep in eps ]):
            raise RuntimeError("A test engine failed to start.")
        elif time.time()-tic > 15:
            raise RuntimeError("Timeout waiting for engines to connect.")
        time.sleep(.1)
        rc.spin()
    rc.close()
    return eps
Exemple #2
0
def add_engines(n=1, profile='iptest', total=False):
    """add a number of engines to a given profile.
    
    If total is True, then already running engines are counted, and only
    the additional engines necessary (if any) are started.
    """
    rc = Client(profile=profile)
    base = len(rc)

    if total:
        n = max(n - base, 0)

    eps = []
    for i in range(n):
        ep = TestProcessLauncher()
        ep.cmd_and_args = ipengine_cmd_argv + [
            '--profile=%s' % profile, '--log-level=50',
            '--InteractiveShell.colors=nocolor'
        ]
        ep.start()
        launchers.append(ep)
        eps.append(ep)
    tic = time.time()
    while len(rc) < base + n:
        if any([ep.poll() is not None for ep in eps]):
            raise RuntimeError("A test engine failed to start.")
        elif time.time() - tic > 15:
            raise RuntimeError("Timeout waiting for engines to connect.")
        time.sleep(.1)
        rc.spin()
    rc.close()
    return eps
 def test_hubresult_timestamps(self):
     self.minimum_engines(4)
     v = self.client[:]
     ar = v.apply_async(time.sleep, 0.25)
     ar.get(2)
     rc2 = Client(profile='iptest')
     # must have try/finally to close second Client, otherwise
     # will have dangling sockets causing problems
     try:
         time.sleep(0.25)
         hr = rc2.get_result(ar.msg_ids)
         self.assertTrue(hr.elapsed > 0., "got bad elapsed: %s" % hr.elapsed)
         hr.get(1)
         self.assertTrue(hr.wall_time < ar.wall_time + 0.2, "got bad wall_time: %s > %s" % (hr.wall_time, ar.wall_time))
         self.assertEqual(hr.serial_time, ar.serial_time)
     finally:
         rc2.close()
Exemple #4
0
 def test_hubresult_timestamps(self):
     self.minimum_engines(4)
     v = self.client[:]
     ar = v.apply_async(time.sleep, 0.25)
     ar.get(2)
     rc2 = Client(profile='iptest')
     # must have try/finally to close second Client, otherwise
     # will have dangling sockets causing problems
     try:
         time.sleep(0.25)
         hr = rc2.get_result(ar.msg_ids)
         self.assertTrue(hr.elapsed > 0.,
                         "got bad elapsed: %s" % hr.elapsed)
         hr.get(1)
         self.assertTrue(
             hr.wall_time < ar.wall_time + 0.2,
             "got bad wall_time: %s > %s" % (hr.wall_time, ar.wall_time))
         self.assertEqual(hr.serial_time, ar.serial_time)
     finally:
         rc2.close()