diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-05 00:52:00 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-05 00:52:00 (GMT) |
commit | 129226d4eb3641af6eb2a7f4646c59370771f336 (patch) | |
tree | 0d24dbece0b0fdef3b10529bc5595b786af9ba1a /Lib/test | |
parent | 16e7a58472015bb9e58977d3bc6a85a734896210 (diff) | |
download | cpython-129226d4eb3641af6eb2a7f4646c59370771f336.zip cpython-129226d4eb3641af6eb2a7f4646c59370771f336.tar.gz cpython-129226d4eb3641af6eb2a7f4646c59370771f336.tar.bz2 |
Merged revisions 78671 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78671 | florent.xicluna | 2010-03-05 01:47:40 +0100 (ven, 05 mar 2010) | 3 lines
Workaround #3137: Retry SIGINT if it is not received the first time.
test_send_signal should not hang anymore on various Linux distributions.
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_subprocess.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 3de46c6..d581081 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -652,9 +652,20 @@ class POSIXProcessTestCase(unittest.TestCase): p = subprocess.Popen([sys.executable, "-c", "input()"]) # Let the process initialize correctly (Issue #3137) - time.sleep(.1) + time.sleep(0.1) self.assertIs(p.poll(), None) - p.send_signal(signal.SIGINT) + count, maxcount = 0, 3 + # Retry if the process do not receive the SIGINT signal. + while count < maxcount and p.poll() is None: + p.send_signal(signal.SIGINT) + time.sleep(0.1) + count += 1 + if p.poll() is None: + raise support.TestFailed("the subprocess did not receive " + "the signal SIGINT") + elif count > 1: + print("p.send_signal(SIGINT) succeeded " + "after {} attempts".format(count), file=sys.stderr) self.assertNotEqual(p.wait(), 0) def test_kill(self): @@ -839,6 +850,7 @@ def test_main(): ProcessTestCaseNoPoll, HelperFunctionTests) + unit_tests = (POSIXProcessTestCase,) support.run_unittest(*unit_tests) support.reap_children() |