summaryrefslogtreecommitdiffstats
path: root/Lib/selectors.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py21
1 files changed, 4 insertions, 17 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index dfcc125..6d82935 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -276,19 +276,6 @@ class _BaseSelectorImpl(BaseSelector):
def get_map(self):
return self._map
- def _key_from_fd(self, fd):
- """Return the key associated to a given file descriptor.
-
- Parameters:
- fd -- file descriptor
-
- Returns:
- corresponding key, or None if not found
- """
- try:
- return self._fd_to_key[fd]
- except KeyError:
- return None
class SelectSelector(_BaseSelectorImpl):
@@ -336,7 +323,7 @@ class SelectSelector(_BaseSelectorImpl):
if fd in w:
events |= EVENT_WRITE
- key = self._key_from_fd(fd)
+ key = self._fd_to_key.get(fd)
if key:
ready.append((key, events & key.events))
return ready
@@ -426,7 +413,7 @@ class _PollLikeSelector(_BaseSelectorImpl):
if event & ~self._EVENT_WRITE:
events |= EVENT_READ
- key = self._key_from_fd(fd)
+ key = self._fd_to_key.get(fd)
if key:
ready.append((key, events & key.events))
return ready
@@ -479,7 +466,7 @@ if hasattr(select, 'epoll'):
if event & ~select.EPOLLOUT:
events |= EVENT_READ
- key = self._key_from_fd(fd)
+ key = self._fd_to_key.get(fd)
if key:
ready.append((key, events & key.events))
return ready
@@ -574,7 +561,7 @@ if hasattr(select, 'kqueue'):
if flag == select.KQ_FILTER_WRITE:
events |= EVENT_WRITE
- key = self._key_from_fd(fd)
+ key = self._fd_to_key.get(fd)
if key:
ready.append((key, events & key.events))
return ready