Kaydet (Commit) 80e0e2d2 authored tarafından Florent Xicluna's avatar Florent Xicluna

Workaround #3137: Retry SIGINT if it is not received the first time.

test_send_signal should not hang anymore on various Linux distributions.
üst 35a3f579
...@@ -654,9 +654,20 @@ class POSIXProcessTestCase(unittest.TestCase): ...@@ -654,9 +654,20 @@ class POSIXProcessTestCase(unittest.TestCase):
p = subprocess.Popen([sys.executable, "-c", "input()"]) p = subprocess.Popen([sys.executable, "-c", "input()"])
# Let the process initialize correctly (Issue #3137) # Let the process initialize correctly (Issue #3137)
time.sleep(.1) time.sleep(0.1)
self.assertIs(p.poll(), None) 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) self.assertNotEqual(p.wait(), 0)
def test_kill(self): def test_kill(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment