mirror of
https://github.com/linuxserver/docker-python.git
synced 2026-02-19 17:24:19 +08:00
73 lines
2.3 KiB
Diff
73 lines
2.3 KiB
Diff
From aeef8591e41b68341af308e56a744396c66879cc Mon Sep 17 00:00:00 2001
|
|
From: "J. Nick Koston" <nick@koston.org>
|
|
Date: Fri, 14 Jul 2023 08:46:30 -1000
|
|
Subject: [PATCH] gh-106554: replace `_BaseSelectorImpl._key_from_fd` with
|
|
`dict.get` (#106555)
|
|
|
|
---
|
|
Lib/selectors.py | 21 ++++-----------------
|
|
1 file changed, 4 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/Lib/selectors.py b/Lib/selectors.py
|
|
index dfcc125dcd..6d82935445 100644
|
|
--- a/Lib/selectors.py
|
|
+++ b/Lib/selectors.py
|
|
@@ -276,19 +276,6 @@ def close(self):
|
|
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 @@ def select(self, timeout=None):
|
|
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 @@ def select(self, timeout=None):
|
|
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 @@ def select(self, timeout=None):
|
|
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 @@ def select(self, timeout=None):
|
|
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
|
|
--
|
|
2.39.2 (Apple Git-143)
|