[issue31786] In select.poll.poll() ms can be 0 if timeout < 0

STINNER Victor report at bugs.python.org
Mon Oct 16 03:42:38 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

Ok, so it seems like we need 3 rounding modes:

* _PyTime_ROUND_FLOOR: read a clock, like datetime.datetime.now(). We need to round nanoseconds since datetime.datetime only supports 1 us resolution

* _PyTime_ROUND_HALF_EVEN: "round from a Python float" like round(float), used by datetime.datetime.fromtimestamp()

* _PyTime_ROUND_UP: round timeouts, socket.settimeout(), lock.acquire(timeout), poll(timeout), etc.

_PyTime_ROUND_UP and _PyTime_ROUND_CEILING are the same for positive numbers, but using _PyTime_ROUND_CEILING causes this bug: values in ]-0.5; 0.0[ are rounding to zero which gives the wrong behaviour. It seems like _PyTime_ROUND_CEILING is not needed in Python currently.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31786>
_______________________________________


More information about the Python-bugs-list mailing list