mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #20452: select and selectors round (again) timeout away from zero for
poll and epoll Improve also debug info to analyze the issue
This commit is contained in:
parent
31f65044a9
commit
dcd9740ad2
4 changed files with 26 additions and 26 deletions
|
@ -8,6 +8,7 @@ This module allows high-level and efficient I/O multiplexing, built upon the
|
|||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
from collections import namedtuple, Mapping
|
||||
import functools
|
||||
import math
|
||||
import select
|
||||
import sys
|
||||
|
||||
|
@ -369,8 +370,9 @@ if hasattr(select, 'poll'):
|
|||
elif timeout <= 0:
|
||||
timeout = 0
|
||||
else:
|
||||
# Round towards zero
|
||||
timeout = int(timeout * 1000)
|
||||
# poll() has a resolution of 1 millisecond, round away from
|
||||
# zero to wait *at least* timeout seconds.
|
||||
timeout = int(math.ceil(timeout * 1e3))
|
||||
ready = []
|
||||
try:
|
||||
fd_event_list = self._poll.poll(timeout)
|
||||
|
@ -430,6 +432,10 @@ if hasattr(select, 'epoll'):
|
|||
timeout = -1
|
||||
elif timeout <= 0:
|
||||
timeout = 0
|
||||
else:
|
||||
# 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)
|
||||
ready = []
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue