2014/1/24 Ben Darnell <[email protected]>: > The epoll change in > https://code.google.com/p/tulip/source/detail?r=5b7e17a75ba4b9bdaab5969a787e904137a53aee > doesn't work. An integer number of milliseconds cannot be represented > exactly as a floating-point number of seconds, so you lose precision when > passing the adjusted timeout into epoll_wait and it rounds down to zero > again: > >>>> int(math.ceil(0.0005 * 1e3) / 1e3) > 0
PollSelector uses int(math.ceil(timeout * 1e3)), example: >>> int(math.ceil(0.0005 * 1e3)) 1 EpollSelector uses math.ceil(timeout * 1e3) * 1e-3, example: >>> math.ceil(0.0005 * 1e3) * 1e-3 0.001 And this value is passed to epoll.poll() which computes: timeout = (int)ceil(dtimeout * 1000.0) But it looks like all these rounding functions are not enough: http://bugs.python.org/issue20311#msg208927 I proposed a different patch reverting my changes in select and selectors module and use instead a new granularity to round timings only in asyncio, in BaseEventLoop._run_once(). The granularity uses not only the resolution of the selector, but also the resolution of the clock. It has at least an impact on Windows (clock resolution: 15.6 ms) and FreeBSD (kqueue resolution: 1e-9, clock: 11-e9). Victor
