summaryrefslogtreecommitdiff
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-20 11:20:44 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-20 11:20:44 +0000
commita6166dac9452140fd76f4f94f8d0334719d78641 (patch)
tree79de22f8e73c174da82796704d2a1d3c24c36ecb /Lib/test/test_subprocess.py
parent25278efac745ce4a50e737484fbdd3d09307504c (diff)
downloadcpython-git-a6166dac9452140fd76f4f94f8d0334719d78641.tar.gz
Merged revisions 84909-84913 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84909 | antoine.pitrou | 2010-09-20 00:46:05 +0200 (lun., 20 sept. 2010) | 3 lines Try to fix test_subprocess on "x86 debian parallel 3.x" buildbot ........ r84910 | antoine.pitrou | 2010-09-20 01:06:53 +0200 (lun., 20 sept. 2010) | 3 lines Try to make signal-sending tests in test_subprocess more robust on slow machines ........ r84911 | antoine.pitrou | 2010-09-20 01:28:30 +0200 (lun., 20 sept. 2010) | 3 lines Make error more explicit in test_finalize_with_trace ........ r84912 | antoine.pitrou | 2010-09-20 02:12:19 +0200 (lun., 20 sept. 2010) | 3 lines Try to fix buildbot failure (#9902) ........ r84913 | antoine.pitrou | 2010-09-20 03:33:21 +0200 (lun., 20 sept. 2010) | 3 lines Try a more robust implementation of _kill_process ........
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 4f9ccebcc3..854e43d707 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -717,24 +717,20 @@ class POSIXProcessTestCase(BaseTestCase):
def _kill_process(self, method, *args):
# Do not inherit file handles from the parent.
# It should fix failures on some platforms.
- p = subprocess.Popen([sys.executable, "-c", "input()"], close_fds=True,
- 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
-
- self.assertIsNotNone(p.poll(), "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)
+ """],
+ close_fds=True,
+ 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)
return p
def test_send_signal(self):