mirror of https://github.com/python/cpython
Fix #8405 for slow buildbots. Remove the sleep on startup and move the
pipe communication into a loop to retry in case a buildbot gets even slower.
This commit is contained in:
parent
b41afb5544
commit
83cba05c30
|
@ -706,17 +706,22 @@ class Win32KillTests(unittest.TestCase):
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE)
|
||||||
|
|
||||||
# Let the process start up (See #3137)
|
count, max = 0, 100
|
||||||
time.sleep(0.5)
|
while count < max and proc.poll() is None:
|
||||||
|
# Create a string buffer to store the result of stdout from the pipe
|
||||||
# Create a string buffer to store the result of stdout from the pipe
|
buf = ctypes.create_string_buffer(len(msg))
|
||||||
buf = ctypes.create_string_buffer(len(msg))
|
# Obtain the text currently in proc.stdout
|
||||||
# Obtain the text currently in proc.stdout
|
# Bytes read/avail/left are left as NULL and unused
|
||||||
# Bytes read/avail/left are left as NULL and unused
|
rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()),
|
||||||
rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()), buf,
|
buf, ctypes.sizeof(buf), None, None, None)
|
||||||
ctypes.sizeof(buf), None, None, None)
|
self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
|
||||||
self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
|
if buf.value:
|
||||||
self.assertEqual(msg, buf.value)
|
self.assertEqual(msg, buf.value)
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
count += 1
|
||||||
|
else:
|
||||||
|
self.fail("Did not receive communication from the subprocess")
|
||||||
|
|
||||||
os.kill(proc.pid, sig)
|
os.kill(proc.pid, sig)
|
||||||
self.assertEqual(proc.wait(), sig)
|
self.assertEqual(proc.wait(), sig)
|
||||||
|
|
Loading…
Reference in New Issue