[Python-checkins] cpython: Issue #23485: Fix test_signal, select.select() now retries the syscall if the

victor.stinner python-checkins at python.org
Mon Mar 30 22:10:10 CEST 2015


https://hg.python.org/cpython/rev/17b6d0d7da00
changeset: 95305:17b6d0d7da00
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Mar 30 22:09:14 2015 +0200
summary:
 Issue #23485: Fix test_signal, select.select() now retries the syscall if the
signal handler does not raise an exception
files:
 Lib/test/test_signal.py | 20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -418,13 +418,20 @@
 TIMEOUT_FULL = 10
 TIMEOUT_HALF = 5
 
+ class InterruptSelect(Exception):
+ pass
+
+ def handler(signum, frame):
+ raise InterruptSelect
+ signal.signal(signal.SIGALRM, handler)
+
 signal.alarm(1)
 
 # We attempt to get a signal during the sleep,
 # before select is called
 try:
 select.select([], [], [], TIMEOUT_FULL)
- except InterruptedError:
+ except InterruptSelect:
 pass
 else:
 raise Exception("select() was not interrupted")
@@ -445,15 +452,22 @@
 TIMEOUT_FULL = 10
 TIMEOUT_HALF = 5
 
+ class InterruptSelect(Exception):
+ pass
+
+ def handler(signum, frame):
+ raise InterruptSelect
+ signal.signal(signal.SIGALRM, handler)
+
 signal.alarm(1)
 before_time = time.monotonic()
 # We attempt to get a signal during the select call
 try:
 select.select([read], [], [], TIMEOUT_FULL)
- except OSError:
+ except InterruptSelect:
 pass
 else:
- raise Exception("OSError not raised")
+ raise Exception("select() was not interrupted")
 after_time = time.monotonic()
 dt = after_time - before_time
 if dt >= TIMEOUT_HALF:
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /