diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-12-08 17:22:33 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-12-08 17:22:33 (GMT) |
commit | 7f98d3ecb87ec4c753e7299cc09b87b54e686e59 (patch) | |
tree | c0a6c3d14705dfebe7146bf43bba696a605ec252 /Lib/selectors.py | |
parent | e3e8b07bcbb12cb09519495700fdbe3e4c9b9836 (diff) | |
parent | d60ef4aa9daff89af06117e7e2ae83adfb8c9dce (diff) | |
download | cpython-7f98d3ecb87ec4c753e7299cc09b87b54e686e59.zip cpython-7f98d3ecb87ec4c753e7299cc09b87b54e686e59.tar.gz cpython-7f98d3ecb87ec4c753e7299cc09b87b54e686e59.tar.bz2 |
selectors: Make sure EpollSelecrtor.select() works when no FD is registered.
Closes issue #23009.
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r-- | Lib/selectors.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py index 4e9ae6e..ad7afe2 100644 --- a/Lib/selectors.py +++ b/Lib/selectors.py @@ -418,7 +418,12 @@ if hasattr(select, 'epoll'): # epoll_wait() has a resolution of 1 millisecond, round away # from zero to wait *at least* timeout seconds. timeout = math.ceil(timeout * 1e3) * 1e-3 - max_ev = len(self._fd_to_key) + + # epoll_wait() expectcs `maxevents` to be greater than zero; + # we want to make sure that `select()` can be called when no + # FD is registered. + max_ev = max(len(self._fd_to_key), 1) + ready = [] try: fd_event_list = self._epoll.poll(timeout, max_ev) |