Commit c179a55a authored by Victor Stinner's avatar Victor Stinner

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

parent 850f313d
...@@ -354,10 +354,12 @@ if hasattr(select, 'poll'): ...@@ -354,10 +354,12 @@ if hasattr(select, 'poll'):
def select(self, timeout=None): def select(self, timeout=None):
if timeout is None: if timeout is None:
timeout = None timeout = None
elif timeout < 0: elif timeout <= 0:
timeout = 0 timeout = 0
else: 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 = [] ready = []
try: try:
fd_event_list = self._poll.poll(timeout) fd_event_list = self._poll.poll(timeout)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment