[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-10-01 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1ee0f94d16f150356a4b9b0a39d44ba1d2d5b9fc by Victor Stinner in 
branch 'main':
bpo-41710: PyThread_acquire_lock_timed() uses sem_clockwait() (GH-28662)
https://github.com/python/cpython/commit/1ee0f94d16f150356a4b9b0a39d44ba1d2d5b9fc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-10-01 Thread Mike Crowe


Mike Crowe  added the comment:

vstinner wrote:
> The glibc 2.30 adds pthread_cond_clockwait() which could be used to use
> CLOCK_MONOTONIC. But if pthread_cond_clockwait() is available (glibc 
> 2.30 or newer), it expects that pthread_condattr_setclock() is also 
> available. So I'm not sure that it's worth it to change 
> PyCOND_TIMEDWAIT().

That's correct. The only time that pthread_cond_clockwait is essential is if 
you don't know which clock you're going to need to use for the wait at the time 
of condition variable creation. (This is true for a generic condition variable 
wrapper that can be passed absolute timeouts using different clocks like the 
C++ std::condition_variable.)

However, sem_clockwait is the only way to wait on a semaphore using 
CLOCK_MONOTONIC, so it is worth using that rather than sem_timedwait if it's 
available. Similarly for pthread_mutex_clocklock.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:

On Unix, PyCOND_TIMEDWAIT() is implemented with pthread_cond_timedwait(). If 
pthread_condattr_setclock() is available, it uses CLOCK_MONOTONIC. Otherwise, 
it uses CLOCK_REALTIME.

The glibc 2.30 adds pthread_cond_clockwait() which could be used to use 
CLOCK_MONOTONIC. But if pthread_cond_clockwait() is available (glibc 2.30 or 
newer), it expects that pthread_condattr_setclock() is also available. So I'm 
not sure that it's worth it to change PyCOND_TIMEDWAIT().

See the _PyThread_cond_after() function which computes an absolute timestamp 
(timespec) from a relative timeout in microseconds.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27027
pull_request: https://github.com/python/cpython/pull/28662

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b34dd58fee707b8044beaf878962a6fa12b304dc by Victor Stinner in 
branch 'main':
bpo-41710: Document _PyTime_t API in pytime.h (GH-28647)
https://github.com/python/cpython/commit/b34dd58fee707b8044beaf878962a6fa12b304dc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27015
pull_request: https://github.com/python/cpython/pull/28647

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 37b8294d6295ca12553fd7c98778be71d24f4b24 by Victor Stinner in 
branch 'main':
bpo-41710: PyThread_acquire_lock_timed() clamps the timout (GH-28643)
https://github.com/python/cpython/commit/37b8294d6295ca12553fd7c98778be71d24f4b24


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 0231b6da45b610d33ee4e99bf190e31488d6ab26 by Victor Stinner in 
branch 'main':
bpo-41710: Fix building pytime.c on Windows (GH-28644)
https://github.com/python/cpython/commit/0231b6da45b610d33ee4e99bf190e31488d6ab26


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27012
pull_request: https://github.com/python/cpython/pull/28644

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27011
pull_request: https://github.com/python/cpython/pull/28643

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d62d925823b005c33b432e527562b573a3a89635 by Victor Stinner in 
branch 'main':
bpo-41710: Add pytime_add() and pytime_mul() (GH-28642)
https://github.com/python/cpython/commit/d62d925823b005c33b432e527562b573a3a89635


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27010
pull_request: https://github.com/python/cpython/pull/28642

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 09796f2f142fdb1214f34a3ca917959ecb32a88b by Victor Stinner in 
branch 'main':
bpo-41710: Add _PyTime_AsTimespec_clamp() (GH-28629)
https://github.com/python/cpython/commit/09796f2f142fdb1214f34a3ca917959ecb32a88b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-29 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +26999
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28629

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-13 Thread STINNER Victor


Change by STINNER Victor :


--
title: Timeout is affected by jumps in system time -> acquire(timeout) of 
threading.Lock and threading.Condition is affected by jumps in system time: 
Python should use sem_clockwait(CLOCK_MONOTONIC)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com