summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-15 17:53:13 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-15 17:53:13 (GMT)
commit775b2dd778eb3a577076aba634d7f2afb489d63f (patch)
treedb10b2d4f4beaa81b94491ed5d559c3b701e65da /Lib
parent53510cda598125a82b643af6eca46dd0f26099b3 (diff)
downloadcpython-775b2dd778eb3a577076aba634d7f2afb489d63f.zip
cpython-775b2dd778eb3a577076aba634d7f2afb489d63f.tar.gz
cpython-775b2dd778eb3a577076aba634d7f2afb489d63f.tar.bz2
test_io: check_interrupted_write() now cancels the alarm if ZeroDivisionError
exception was not raised. Before the process was killed by SIGALRM in another random test (1 second later)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_io.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 5fb68b4..54c0161 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3070,15 +3070,18 @@ class SignalsTest(unittest.TestCase):
try:
wio = self.io.open(w, **fdopen_kwargs)
t.start()
- signal.alarm(1)
# Fill the pipe enough that the write will be blocking.
# It will be interrupted by the timer armed above. Since the
# other thread has read one byte, the low-level write will
# return with a successful (partial) result rather than an EINTR.
# The buffered IO layer must check for pending signal
# handlers, which in this case will invoke alarm_interrupt().
- self.assertRaises(ZeroDivisionError,
- wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1))
+ signal.alarm(1)
+ try:
+ self.assertRaises(ZeroDivisionError,
+ wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1))
+ finally:
+ signal.alarm(0)
t.join()
# We got one byte, get another one and check that it isn't a
# repeat of the first one.