mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
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 ........
This commit is contained in:
parent
25278efac7
commit
a6166dac94
2 changed files with 22 additions and 21 deletions
|
@ -717,24 +717,20 @@ class POSIXProcessTestCase(BaseTestCase):
|
||||||
def _kill_process(self, method, *args):
|
def _kill_process(self, method, *args):
|
||||||
# Do not inherit file handles from the parent.
|
# Do not inherit file handles from the parent.
|
||||||
# It should fix failures on some platforms.
|
# It should fix failures on some platforms.
|
||||||
p = subprocess.Popen([sys.executable, "-c", "input()"], close_fds=True,
|
p = subprocess.Popen([sys.executable, "-c", """if 1:
|
||||||
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
import sys, time
|
||||||
|
sys.stdout.write('x\\n')
|
||||||
# Let the process initialize (Issue #3137)
|
sys.stdout.flush()
|
||||||
time.sleep(0.1)
|
time.sleep(30)
|
||||||
# The process should not terminate prematurely
|
"""],
|
||||||
self.assertIsNone(p.poll())
|
close_fds=True,
|
||||||
# Retry if the process do not receive the signal.
|
stdin=subprocess.PIPE,
|
||||||
count, maxcount = 0, 3
|
stdout=subprocess.PIPE,
|
||||||
while count < maxcount and p.poll() is None:
|
stderr=subprocess.PIPE)
|
||||||
getattr(p, method)(*args)
|
# Wait for the interpreter to be completely initialized before
|
||||||
time.sleep(0.1)
|
# sending any signal.
|
||||||
count += 1
|
p.stdout.read(1)
|
||||||
|
getattr(p, method)(*args)
|
||||||
self.assertIsNotNone(p.poll(), "the subprocess did not terminate")
|
|
||||||
if count > 1:
|
|
||||||
print >>sys.stderr, ("p.{}{} succeeded after "
|
|
||||||
"{} attempts".format(method, args, count))
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def test_send_signal(self):
|
def test_send_signal(self):
|
||||||
|
|
|
@ -307,7 +307,7 @@ class ThreadTests(BaseTestCase):
|
||||||
# Issue1733757
|
# Issue1733757
|
||||||
# Avoid a deadlock when sys.settrace steps into threading._shutdown
|
# Avoid a deadlock when sys.settrace steps into threading._shutdown
|
||||||
import subprocess
|
import subprocess
|
||||||
rc = subprocess.call([sys.executable, "-c", """if 1:
|
p = subprocess.Popen([sys.executable, "-c", """if 1:
|
||||||
import sys, threading
|
import sys, threading
|
||||||
|
|
||||||
# A deadlock-killer, to prevent the
|
# A deadlock-killer, to prevent the
|
||||||
|
@ -327,9 +327,14 @@ class ThreadTests(BaseTestCase):
|
||||||
return func
|
return func
|
||||||
|
|
||||||
sys.settrace(func)
|
sys.settrace(func)
|
||||||
"""])
|
"""],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
rc = p.returncode
|
||||||
self.assertFalse(rc == 2, "interpreted was blocked")
|
self.assertFalse(rc == 2, "interpreted was blocked")
|
||||||
self.assertTrue(rc == 0, "Unexpected error")
|
self.assertTrue(rc == 0,
|
||||||
|
"Unexpected error: " + repr(stderr))
|
||||||
|
|
||||||
def test_join_nondaemon_on_shutdown(self):
|
def test_join_nondaemon_on_shutdown(self):
|
||||||
# Issue 1722344
|
# Issue 1722344
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue