diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 19:38:00 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 19:38:00 (GMT) |
commit | 3c7d6e069331ceab0da6b794e4069f07bb3d4aac (patch) | |
tree | 42284993b3b0cdc127c69218140a2650e73b8e60 /Lib/test/eintrdata | |
parent | fa09beb1508f782b51ba0a2815c07e0294f40e95 (diff) | |
download | cpython-3c7d6e069331ceab0da6b794e4069f07bb3d4aac.zip cpython-3c7d6e069331ceab0da6b794e4069f07bb3d4aac.tar.gz cpython-3c7d6e069331ceab0da6b794e4069f07bb3d4aac.tar.bz2 |
Issue #23485: select.poll.poll() is now retried when interrupted by a signal
Diffstat (limited to 'Lib/test/eintrdata')
-rw-r--r-- | Lib/test/eintrdata/eintr_tester.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py index 82cef83..3da964d 100644 --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -38,8 +38,12 @@ class EINTRBaseTest(unittest.TestCase): cls.signal_period) @classmethod - def tearDownClass(cls): + def stop_alarm(cls): signal.setitimer(signal.ITIMER_REAL, 0, 0) + + @classmethod + def tearDownClass(cls): + cls.stop_alarm() signal.signal(signal.SIGALRM, cls.orig_handler) @classmethod @@ -260,7 +264,7 @@ class TimeEINTRTest(EINTRBaseTest): def test_sleep(self): t0 = time.monotonic() time.sleep(self.sleep_time) - signal.alarm(0) + self.stop_alarm() dt = time.monotonic() - t0 self.assertGreaterEqual(dt, self.sleep_time) @@ -311,7 +315,17 @@ class SelectEINTRTest(EINTRBaseTest): def test_select(self): t0 = time.monotonic() select.select([], [], [], self.sleep_time) - signal.alarm(0) + self.stop_alarm() + dt = time.monotonic() - t0 + self.assertGreaterEqual(dt, self.sleep_time) + + @unittest.skipUnless(hasattr(select, 'poll'), 'need select.poll') + def test_poll(self): + poller = select.poll() + + t0 = time.monotonic() + poller.poll(self.sleep_time * 1e3) + self.stop_alarm() dt = time.monotonic() - t0 self.assertGreaterEqual(dt, self.sleep_time) |