summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-05-28 15:49:21 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-05-28 15:49:21 (GMT)
commit83cba05c30db591e7425dfbfb4b87a179f98aa70 (patch)
treecd8362628a1181e074005edfae459651fa5cf616 /Lib/test/test_os.py
parentb41afb55446cf57abca6a8bcf1b38fe84b0d9e6b (diff)
downloadcpython-83cba05c30db591e7425dfbfb4b87a179f98aa70.zip
cpython-83cba05c30db591e7425dfbfb4b87a179f98aa70.tar.gz
cpython-83cba05c30db591e7425dfbfb4b87a179f98aa70.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index e198252..67de20e 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -706,17 +706,22 @@ class Win32KillTests(unittest.TestCase):
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
- # Let the process start up (See #3137)
- time.sleep(0.5)
-
- # Create a string buffer to store the result of stdout from the pipe
- buf = ctypes.create_string_buffer(len(msg))
- # Obtain the text currently in proc.stdout
- # Bytes read/avail/left are left as NULL and unused
- rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()), buf,
- ctypes.sizeof(buf), None, None, None)
- self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
- self.assertEqual(msg, buf.value)
+ count, max = 0, 100
+ while count < max and proc.poll() is None:
+ # Create a string buffer to store the result of stdout from the pipe
+ buf = ctypes.create_string_buffer(len(msg))
+ # Obtain the text currently in proc.stdout
+ # Bytes read/avail/left are left as NULL and unused
+ rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()),
+ buf, ctypes.sizeof(buf), None, None, None)
+ self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
+ if 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)
self.assertEqual(proc.wait(), sig)