[issue14222] Using time.time() in Queue.get breaks when system time is changed

Charles-François Natali report at bugs.python.org
Wed Mar 14 18:02:43 CET 2012


Charles-François Natali <neologix at free.fr> added the comment:

Random thoughts:
- as noted by Antoine, it probably affects a lot of code throughout
the standard library
- sem_timedwait() (used by lock.acquire() on POSIX) is affected (the
implementation using a condition variable could use
pthread_condattr_setclock(), see issue #12822)
- there's a side effect to that change: on Linux, when the system is
suspended, CLOCK_MONOTONIC stops: so on resume, you'd have to wait for
the complete timeout to expire, whereas with time.time() you'll break
out early

That being said, it's probably a good idea.

As for the patches, I don't really like the idea of having to use this
idiom everywhere:

try:
    from time import monotonic as _time
    _time()
except (ImportError, OSError):
    from time import _time

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14222>
_______________________________________


More information about the Python-bugs-list mailing list