예제 #1
0
 def test_unused_pid(self):
     """Waiting on an unused PID should return immediately"""
     unused_pid = self._unused_pid()
     t0 = time.time()
     pidmon.waitpid(unused_pid)
     t1 = time.time()
     time_taken = t1 - t0
     self.assertLess(time_taken, .5)
예제 #2
0
 def test_childpid(self, delay=.05):
     """waitpid handles direct child (nothing os.waitpid can't do)"""
     p1 = _utils.DummyProcess()
     try:
         p1.start()
         self._stop_process_after(p1, delay)
         t0 = time.time()
         pidmon.waitpid(p1.process.pid)
     finally:
         p1.stop()
     t1 = time.time()
     assert (delay < t1 - t0), "died {:.2f}s into {:.2f}s delay".format(t1 - t0, delay)
예제 #3
0
 def test_grandchildpid(self, delay=.05):
     """waitpid handles grandchild (os.waitpid can't do this)"""
     p1 = _utils.SpawnOnceProcess()
     try:
         p1.start()
         p1_handle = pidmon.Process(p1.process.pid)
         (p2_handle,) = p1_handle.children
         self._stop_process_after(p1, delay)
         t0 = time.time()
         pidmon.waitpid(p1.process.pid)
     finally:
         p1.stop()
     t1 = time.time()
     assert (delay < t1 - t0), "died {:.2f}s into {:.2f}s delay".format(t1 - t0, delay)