Skip to content

Commit b608fcd

Browse files
closes bpo-34004: Skip lock interruption tests on musl. (GH-9224)
Returning EINTR from pthread semaphore or lock acquisition is an optional POSIX feature. musl does not provide this feature, so some threadsignal tests fail when Python is built against it. There's no good way to test for musl, so we skip if we're on Linux and not using glibc pthreads. Also, hedge in the threading documentation about when we can provide interrupts from lock acquisition. (cherry picked from commit 5b10d51) Co-authored-by: Benjamin Peterson <[email protected]>
1 parent 329ea4e commit b608fcd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Doc/library/threading.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ All methods are executed atomically.
400400
The *timeout* parameter is new.
401401

402402
.. versionchanged:: 3.2
403-
Lock acquires can now be interrupted by signals on POSIX.
403+
Lock acquisition can now be interrupted by signals on POSIX if the
404+
underlying threading implementation supports it.
404405

405406

406407
.. method:: release()

Lib/test/test_threadsignals.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def alarm_interrupt(self, sig, frame):
7878

7979
@unittest.skipIf(USING_PTHREAD_COND,
8080
'POSIX condition variables cannot be interrupted')
81+
@unittest.skipIf(sys.platform.startswith('linux') and
82+
not sys.thread_info.version,
83+
'Issue 34004: musl does not allow interruption of locks '
84+
'by signals.')
8185
# Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD
8286
@unittest.skipIf(sys.platform.startswith('openbsd'),
8387
'lock cannot be interrupted on OpenBSD')
@@ -105,6 +109,10 @@ def test_lock_acquire_interruption(self):
105109

106110
@unittest.skipIf(USING_PTHREAD_COND,
107111
'POSIX condition variables cannot be interrupted')
112+
@unittest.skipIf(sys.platform.startswith('linux') and
113+
not sys.thread_info.version,
114+
'Issue 34004: musl does not allow interruption of locks '
115+
'by signals.')
108116
# Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD
109117
@unittest.skipIf(sys.platform.startswith('openbsd'),
110118
'lock cannot be interrupted on OpenBSD')

0 commit comments

Comments
 (0)