summaryrefslogtreecommitdiff
path: root/Lib/selectors.py
diff options
context:
space:
mode:
authorRussell Davis <551404+russelldavis@users.noreply.github.com>2020-04-15 11:57:06 -0700
committerGitHub <noreply@github.com>2020-04-15 11:57:06 -0700
commitba1bcffe5cafc1bb0ac6fdf9ecef51e75e342707 (patch)
tree59682606714c5402a5bb72f8926a4d5f7b69323d /Lib/selectors.py
parent4b4e90a51848578dc06341777a929a0be4f4757f (diff)
downloadcpython-git-ba1bcffe5cafc1bb0ac6fdf9ecef51e75e342707.tar.gz
bpo-29255: Wait in KqueueSelector.select when no fds are registered (GH-19508)
Also partially fixes bpo-25680 (there's still a discrepancy in behavior on Windows that needs to be fixed).
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index a9a0801ef0..90251dc34a 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -552,7 +552,10 @@ 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)
+ # If max_ev is 0, kqueue will ignore the timeout. For consistent
+ # behavior with the other selector classes, we prevent that here
+ # (using max). See https://bugs.python.org/issue29255
+ max_ev = max(len(self._fd_to_key), 1)
ready = []
try:
kev_list = self._selector.control(None, max_ev, timeout)