]> granicus.if.org Git - python/commitdiff
Issue #23485: Fix test_signal, select.select() now retries the syscall if the
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 20:09:14 +0000 (22:09 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 20:09:14 +0000 (22:09 +0200)
signal handler does not raise an exception

Lib/test/test_signal.py

index 8718eae689c39ce739ba69c1e663ad11f5b67132..65b36de9e190fe90f96051d3bd72ee45bcca7bc5 100644 (file)
@@ -418,13 +418,20 @@ class WakeupSignalTests(unittest.TestCase):
             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 @@ class WakeupSignalTests(unittest.TestCase):
             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: