python3: use monotonic clock for condvar if possible
PATCH 1/1 python3: use monotonic clock for condvar if possible
From: Zqiang <[email protected]>
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.
This patch will make condvar use monotonic clock.
Refence: https://bugs.python.org/issue41710
--- meta/recipes-devtools/python/python3_3.9.5.bb | 3 +++ 1 file changed, 3 insertions(+)
meta/recipes-devtools/python/python3_3.9.5.bb +3 -0
@@ -73,6 +73,9 @@ DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/li DEPENDS_append_class-target = " python3-native" DEPENDS_append_class-nativesdk = " python3-native" +# force to use the mutex+cond implementation +CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES" + EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}" EXTRA_OECONF_append_class-native = " --bindir=${bindir}/${PN}"
Signature · 1 line
2.17.1
Quoted 9 lines · Qiang
From: Zqiang <[email protected]>
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.
This patch will make condvar use monotonic clock.
Refence: https://bugs.python.org/issue41710
Should this be backported to the 3.8.10 and 3.8.11 recipes in dunfell?
Steve
Quoted 25 lines
Signed-off-by Zqiang <[email protected]>--- meta/recipes-devtools/python/python3_3.9.5.bb | 3 +++ 1 file changed, 3 insertions(+)meta/recipes-devtools/python/python3_3.9.5.bb +3
-1@@ -73,6 +73,9 @@ DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/li DEPENDS_append_class-target = " python3-native" DEPENDS_append_class-nativesdk = " python3-native" +# force to use the mutex+cond implementation +CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES" + EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}" EXTRA_OECONF_append_class-native = " --bindir=${bindir}/${PN}" --2.17.1
Quoted 6 lines · Qiang
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.
This patch will make condvar use monotonic clock.
Refence: https://bugs.python.org/issue41710
That doesn't quite make sense to me.
As referenced in that bug report,
https://github.com/python/cpython/commit/001fee14e0f2ba5f41fb733adc69d5965925a094
uses monotonic clocks by default. That was in 3.8.0 onwards.
So, why is this change to pretend that the semaphore is broken needed?
Ross
I too do not think this is sufficiently explained. All of python ptests pass, so there needs to be a demonstrator of incorrect behavior, or let's just revert it.
Alex
Quoted 23 lines · Ross Burton
Quoted 6 lines · Qiang
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.
This patch will make condvar use monotonic clock.
Refence: https://bugs.python.org/issue41710That doesn't quite make sense to me.
As referenced in that bug report,
https://github.com/python/cpython/commit/001fee14e0f2ba5f41fb733adc69d5965925a094
uses monotonic clocks by default. That was in 3.8.0 onwards.So, why is this change to pretend that the semaphore is broken needed?
Ross
Quoted 3 lines · Alexander Kanavin
I too do not think this is sufficiently explained. All of python ptests pass, so there needs to be a demonstrator of incorrect behavior, or let's just revert it.
I agree regarding the lack of explanation. However, even if the problem is real (which it looks like it is based on https://bugs.python.org/issue41710)
then it wouldn't be expected to cause test failures unless the system clock was being warped at inconvenient times during the tests.
Thanks.
Mike.
Quoted 6 lines · Mike Crowe
I agree regarding the lack of explanation. However, even if the problem is real (which it looks like it is based on
https://bugs.python.org/issue41710)
then it wouldn't be expected to cause test failures unless the system clock was being warped at inconvenient times during the tests.
So can we just patch python to use the right glibc function with the right clock type, and send the patch upstream then? Much better than the workaround that was merged.
Alex
Quoted 10 lines · Alexander Kanavin
Quoted 5 lines · Mike Crowe
I agree regarding the lack of explanation. However, even if the problem is real (which it looks like it is based on
https://bugs.python.org/issue41710)
then it wouldn't be expected to cause test failures unless the system clock was being warped at inconvenient times during the tests.So can we just patch python to use the right glibc function with the right clock type, and send the patch upstream then? Much better than the workaround that was merged.
In theory, yes. I've no idea how hard that is though. It probably requires adding build-time detection of whether the new functions are available to avoid breaking other/older target operating systems.
Mike.