Skip to content

Commit

Permalink
closes bpo-34004: Skip lock interruption tests on musl. (GH-9224)
Browse files Browse the repository at this point in the history
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 <benjamin@python.org>
  • Loading branch information
miss-islington and benjaminp committed Sep 12, 2018
1 parent aa12534 commit 5a435ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Doc/library/threading.rst
Expand Up @@ -400,7 +400,8 @@ All methods are executed atomically.
The *timeout* parameter is new.

.. versionchanged:: 3.2
Lock acquires can now be interrupted by signals on POSIX.
Lock acquisition can now be interrupted by signals on POSIX if the
underlying threading implementation supports it.


.. method:: release()
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_threadsignals.py
Expand Up @@ -78,6 +78,10 @@ def alarm_interrupt(self, sig, frame):

@unittest.skipIf(USING_PTHREAD_COND,
'POSIX condition variables cannot be interrupted')
@unittest.skipIf(sys.platform.startswith('linux') and
not sys.thread_info.version,
'Issue 34004: musl does not allow interruption of locks '
'by signals.')
# Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD
@unittest.skipIf(sys.platform.startswith('openbsd'),
'lock cannot be interrupted on OpenBSD')
Expand Down Expand Up @@ -105,6 +109,10 @@ def test_lock_acquire_interruption(self):

@unittest.skipIf(USING_PTHREAD_COND,
'POSIX condition variables cannot be interrupted')
@unittest.skipIf(sys.platform.startswith('linux') and
not sys.thread_info.version,
'Issue 34004: musl does not allow interruption of locks '
'by signals.')
# Issue #20564: sem_timedwait() cannot be interrupted on OpenBSD
@unittest.skipIf(sys.platform.startswith('openbsd'),
'lock cannot be interrupted on OpenBSD')
Expand Down

0 comments on commit 5a435ea

Please sign in to comment.