Mike Crowe added the comment:
glibc v2.30 onwards provides sem_clockwait which can wait on either
CLOCK_MONOTONIC or CLOCK_REALTIME. I failed to notice that
https://sourceware.org/bugzilla/show_bug.cgi?id=14717 existed until today. :(
--
nosy: +mikecrowe
Jonas Norling added the comment:
sys.thread_info = sys.thread_info(name='pthread', lock='semaphore',
version='NPTL 2.31') on my system. Looking at the source I think the semaphore
implementation will be used on all modern Linux systems.
In my tests it works as expected on a Macintosh (3.8.5
STINNER Victor added the comment:
bpo-23428 modified the pthread implementation of conditional variable to use
pthread_condattr_setclock(&ca, CLOCK_MONOTONIC) is available: commit
001fee14e0f2ba5f41fb733adc69d5965925a094. The change should be part of Python
3.8.
What is your sys.thread_info
New submission from Jonas Norling :
The timeout for threading.Lock, threading.Condition, etc, is not using a
monotonic clock — it is affected if the system time (realtime clock) is set.
The attached program can be used to show the problem. It is expected to print
"Took 2.000 s" repeatedly, but