diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-31 10:10:33 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-31 10:10:33 (GMT) |
commit | 45ca48b03d08cdc9959e0577bc84b845931112f6 (patch) | |
tree | eb66f50e3fb83a117fdb522531b8123b3353a4e7 /Lib | |
parent | 4448c08451e947ccf197742d22fa49adba71e363 (diff) | |
download | cpython-45ca48b03d08cdc9959e0577bc84b845931112f6.zip cpython-45ca48b03d08cdc9959e0577bc84b845931112f6.tar.gz cpython-45ca48b03d08cdc9959e0577bc84b845931112f6.tar.bz2 |
Issue #23485: select.devpoll.poll() is now retried when interrupted by a signal
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/selectors.py | 7 | ||||
-rw-r--r-- | Lib/test/eintrdata/eintr_tester.py | 11 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py index a3f2e78..44a6150 100644 --- a/Lib/selectors.py +++ b/Lib/selectors.py @@ -479,11 +479,10 @@ if hasattr(select, 'devpoll'): # devpoll() has a resolution of 1 millisecond, round away from # zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) + + fd_event_list = self._devpoll.poll(timeout) + ready = [] - try: - fd_event_list = self._devpoll.poll(timeout) - except InterruptedError: - return ready for fd, event in fd_event_list: events = 0 if event & ~select.POLLIN: diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py index 4e9b992..f755880 100644 --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -351,6 +351,17 @@ class SelectEINTRTest(EINTRBaseTest): self.stop_alarm() self.assertGreaterEqual(dt, self.sleep_time) + @unittest.skipUnless(hasattr(select, 'devpoll'), 'need select.devpoll') + def test_devpoll(self): + poller = select.devpoll() + self.addCleanup(poller.close) + + t0 = time.monotonic() + poller.poll(self.sleep_time * 1e3) + dt = time.monotonic() - t0 + self.stop_alarm() + self.assertGreaterEqual(dt, self.sleep_time) + def test_main(): support.run_unittest( |