diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-24 19:00:29 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-24 19:00:29 +0000 |
commit | dee0097fe418c066433bc55b90811f0beae0475c (patch) | |
tree | 6f2f1c10135b1f3a3c80c352e5443d519c5ccc2e | |
parent | 517185edcb252bd85c83d96480bf79b85258e1f2 (diff) | |
download | cpython-git-dee0097fe418c066433bc55b90811f0beae0475c.tar.gz |
Merged revisions 84997 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84997 | antoine.pitrou | 2010-09-24 20:57:01 +0200 (ven., 24 sept. 2010) | 3 lines
Make _kill_process more robust under Windows too (see issue #8432)
........
-rw-r--r-- | Lib/test/test_subprocess.py | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 854e43d707..22933db811 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -823,28 +823,22 @@ class Win32ProcessTestCase(BaseTestCase): def _kill_process(self, method, *args): # Some win32 buildbot raises EOFError if stdin is inherited - p = subprocess.Popen([sys.executable, "-c", "input()"], - stdin=subprocess.PIPE, stderr=subprocess.PIPE) - - # Let the process initialize (Issue #3137) - time.sleep(0.1) - # The process should not terminate prematurely - self.assertIsNone(p.poll()) - # Retry if the process do not receive the signal. - count, maxcount = 0, 3 - while count < maxcount and p.poll() is None: - getattr(p, method)(*args) - time.sleep(0.1) - count += 1 - - returncode = p.poll() - self.assertIsNotNone(returncode, "the subprocess did not terminate") - if count > 1: - print >>sys.stderr, ("p.{}{} succeeded after " - "{} attempts".format(method, args, count)) + p = subprocess.Popen([sys.executable, "-c", """if 1: + import sys, time + sys.stdout.write('x\\n') + sys.stdout.flush() + time.sleep(30) + """], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # Wait for the interpreter to be completely initialized before + # sending any signal. + p.stdout.read(1) + getattr(p, method)(*args) _, stderr = p.communicate() self.assertStderrEqual(stderr, '') - self.assertEqual(p.wait(), returncode) + returncode = p.wait() self.assertNotEqual(returncode, 0) def test_send_signal(self): |