def test_wait_timeout(self): # Ensure that wait() honors its "timeout" argument. proc = Process() proc.spawn(['sleep', '10']) self.assertRaises(Timeout, proc.wait, 0.1) proc.terminate() proc.wait() proc.close()
def test_communicate_timeout(self): # Test that communicate() honors its "timeout" argument proc = Process() proc.spawn(['sleep', '10'], stdin=PIPE, stdout=PIPE) buf = b'x' * 1024 self.assertRaises(Timeout, proc.communicate, buf, timeout=0.1) proc.terminate() proc.wait() proc.close()
def test_terminate(self): # Ensure that terminate() kills our child. proc = Process() proc.spawn(['sleep', '1']) proc.terminate() proc.wait() self.assertEqual(proc.returncode, -signal.SIGTERM) proc.terminate() # should not error proc.close()