summaryrefslogtreecommitdiffstats
path: root/Lib/selectors.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-11 17:48:16 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-11 17:48:16 (GMT)
commit90ecfe65e681f6e7f901a101ad1e549e339ea10d (patch)
tree209eb793aba6b6322cdfebe768de1113b9fec3dc /Lib/selectors.py
parenta032e46df64330ec9e6e188d9ea53f594d0a0fbf (diff)
downloadcpython-90ecfe65e681f6e7f901a101ad1e549e339ea10d.zip
cpython-90ecfe65e681f6e7f901a101ad1e549e339ea10d.tar.gz
cpython-90ecfe65e681f6e7f901a101ad1e549e339ea10d.tar.bz2
asyncio: Sync with github repo
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py49
1 files changed, 26 insertions, 23 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index e17ea36..6d569c3 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -310,7 +310,10 @@ class SelectSelector(_BaseSelectorImpl):
def select(self, timeout=None):
timeout = None if timeout is None else max(timeout, 0)
ready = []
- r, w, _ = self._select(self._readers, self._writers, [], timeout)
+ try:
+ r, w, _ = self._select(self._readers, self._writers, [], timeout)
+ except InterruptedError:
+ return ready
r = set(r)
w = set(w)
for fd in r | w:
@@ -359,10 +362,11 @@ if hasattr(select, 'poll'):
# poll() 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._poll.poll(timeout)
-
ready = []
+ try:
+ fd_event_list = self._poll.poll(timeout)
+ except InterruptedError:
+ return ready
for fd, event in fd_event_list:
events = 0
if event & ~select.POLLIN:
@@ -423,9 +427,11 @@ if hasattr(select, 'epoll'):
# FD is registered.
max_ev = max(len(self._fd_to_key), 1)
- fd_event_list = self._epoll.poll(timeout, max_ev)
-
ready = []
+ try:
+ fd_event_list = self._epoll.poll(timeout, max_ev)
+ except InterruptedError:
+ return ready
for fd, event in fd_event_list:
events = 0
if event & ~select.EPOLLIN:
@@ -439,10 +445,8 @@ if hasattr(select, 'epoll'):
return ready
def close(self):
- try:
- self._epoll.close()
- finally:
- super().close()
+ self._epoll.close()
+ super().close()
if hasattr(select, 'devpoll'):
@@ -481,10 +485,11 @@ 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:
@@ -498,10 +503,8 @@ if hasattr(select, 'devpoll'):
return ready
def close(self):
- try:
- self._devpoll.close()
- finally:
- super().close()
+ self._devpoll.close()
+ super().close()
if hasattr(select, 'kqueue'):
@@ -552,9 +555,11 @@ if hasattr(select, 'kqueue'):
def select(self, timeout=None):
timeout = None if timeout is None else max(timeout, 0)
max_ev = len(self._fd_to_key)
- kev_list = self._kqueue.control(None, max_ev, timeout)
-
ready = []
+ try:
+ kev_list = self._kqueue.control(None, max_ev, timeout)
+ except InterruptedError:
+ return ready
for kev in kev_list:
fd = kev.ident
flag = kev.filter
@@ -570,10 +575,8 @@ if hasattr(select, 'kqueue'):
return ready
def close(self):
- try:
- self._kqueue.close()
- finally:
- super().close()
+ self._kqueue.close()
+ super().close()
# Choose the best implementation, roughly: