GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — gh-108724: Use _PyTime_GetMonotonicClock() in parking_lot.c by vstinner · Pull Request #112222 · python/cpython Conversation
|
|
@colesbury @ericsnowcurrently: Please don't use the system clock for locks. It causes too many issues. Using a monotonic clock is more reliable. Sadly, on Windows, the monotonic clock has a resolution of 15.6 ms. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We should use the monotonic clock when available, but this change isn't sufficient:
sem_timedwait does not work with CLOCK_MONOTONIC. (Need sem_clockwait if available)pthread_cond_t needs to be initialized with the right attribute
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| _PyTime_t deadline = _PyTime_Add(_PyTime_GetMonotonicClock(), timeout); | ||
| _PyTime_AsTimespec(deadline, &ts); | ||
|
|
||
| err = sem_timedwait(&sema->platform_sem, &ts); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
# ifdef HAVE_SEM_CLOCKWAIT _PyTime_t deadline = _PyDeadline_Init(timeout); _PyTime_AsTimespec_clamp(deadline, &ts); err = sem_clockwait(&sema->platform_sem, CLOCK_MONOTONIC, &ts); # else _PyTime_t deadline = _PyTime_Add(_PyTime_GetSystemClock(), timeout); _PyTime_AsTimespec_clamp(deadline, &ts); err = sem_timedwait(&sema->platform_sem, &ts); #endif
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh. I made a mechanical change to avoid _PyTime_GetSystemClock(). I didn't see that timestamps are passed to existing functions such as pthread_cond_timedwait(). I mark my PR as a draft for now and will try to update it to address Sam's review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't have time to fix my PR right now. I may try again later ;-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I wrote it up as an issue so that I don't forget about this and in case someone else wants to tackle it first: #112606 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.