summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-05 00:47:40 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-05 00:47:40 (GMT)
commit80e0e2d2d8e648f89e216a6fbcd9b96122a3fa69 (patch)
tree4a6da03409a89504e03d525acc770241d4942cf7 /Lib
parent35a3f57937a701a3b0227b71f3d7dcb7a9bfa1a2 (diff)
downloadcpython-80e0e2d2d8e648f89e216a6fbcd9b96122a3fa69.zip
cpython-80e0e2d2d8e648f89e216a6fbcd9b96122a3fa69.tar.gz
cpython-80e0e2d2d8e648f89e216a6fbcd9b96122a3fa69.tar.bz2
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')
-rw-r--r--Lib/test/test_subprocess.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 1f3b09c..ea4f5ab 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -654,9 +654,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 test_support.TestFailed("the subprocess did not receive "
+ "the signal SIGINT")
+ elif count > 1:
+ print >>sys.stderr, ("p.send_signal(SIGINT) succeeded "
+ "after {} attempts".format(count))
self.assertNotEqual(p.wait(), 0)
def test_kill(self):