diff options
author | J. Nick Koston <nick@koston.org> | 2023-10-11 20:59:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 20:59:27 (GMT) |
commit | 3ac8e6955fedc35e8646bee7e04be6f20205cc1e (patch) | |
tree | 76136e14ea13a9970ecbeac74b0c47ca9b637ecf /Lib/asyncio | |
parent | 41d8ec5a1bae1e5d4452da0a1a0649ace4ecb7b0 (diff) | |
download | cpython-3ac8e6955fedc35e8646bee7e04be6f20205cc1e.zip cpython-3ac8e6955fedc35e8646bee7e04be6f20205cc1e.tar.gz cpython-3ac8e6955fedc35e8646bee7e04be6f20205cc1e.tar.bz2 |
gh-110733: Micro-optimization in BaseEventLoop._run_once (#110735)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/base_events.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index b092c93..956864e 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1907,8 +1907,11 @@ class BaseEventLoop(events.AbstractEventLoop): timeout = 0 elif self._scheduled: # Compute the desired timeout. - when = self._scheduled[0]._when - timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT) + timeout = self._scheduled[0]._when - self.time() + if timeout > MAXIMUM_SELECT_TIMEOUT: + timeout = MAXIMUM_SELECT_TIMEOUT + elif timeout < 0: + timeout = 0 event_list = self._selector.select(timeout) self._process_events(event_list) |