selectors: add a comment to explain why and how poll timeout is rounded

This commit is contained in:
Victor Stinner 2014-01-21 17:49:41 +01:00
parent 781a5441ae
commit 7067b5d927
1 changed files with 4 additions and 2 deletions

View File

@ -354,10 +354,12 @@ if hasattr(select, 'poll'):
def select(self, timeout=None):
if timeout is None:
timeout = None
elif timeout < 0:
elif timeout <= 0:
timeout = 0
else:
timeout = int(math.ceil(timeout * 1000.0))
# 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)