summaryrefslogtreecommitdiff
path: root/Lib/test/test_threadsignals.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-19 23:58:51 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-19 23:58:51 +0200
commit754851f456d0b97c86f2d700e032632323840e29 (patch)
tree366726362ecd8a4849b9fc402eddf6fb2acbf9a5 /Lib/test/test_threadsignals.py
parentcf2a807831ee93ef39e73fcc682894b0695b6143 (diff)
downloadcpython-git-754851f456d0b97c86f2d700e032632323840e29.tar.gz
Issue #11223: Add threading._info() function providing informations about the
thread implementation. Skip test_lock_acquire_interruption() and test_rlock_acquire_interruption() of test_threadsignals if a thread lock is implemented using a POSIX mutex and a POSIX condition variable. A POSIX condition variable cannot be interrupted by a signal (e.g. on Linux, the futex system call is restarted).
Diffstat (limited to 'Lib/test/test_threadsignals.py')
-rw-r--r--Lib/test/test_threadsignals.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
index 46e405ab81..b0bc607285 100644
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -14,6 +14,9 @@ if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
process_pid = os.getpid()
signalled_all=thread.allocate_lock()
+info = thread.info()
+USING_PTHREAD_COND = (info['name'] == 'pthread'
+ and info['lock_implementation'] == 'mutex+cond')
def registerSignals(for_usr1, for_usr2, for_alrm):
usr1 = signal.signal(signal.SIGUSR1, for_usr1)
@@ -70,6 +73,8 @@ class ThreadSignals(unittest.TestCase):
def alarm_interrupt(self, sig, frame):
raise KeyboardInterrupt
+ @unittest.skipIf(USING_PTHREAD_COND,
+ 'POSIX condition variables cannot be interrupted')
def test_lock_acquire_interruption(self):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.
@@ -91,6 +96,8 @@ class ThreadSignals(unittest.TestCase):
finally:
signal.signal(signal.SIGALRM, oldalrm)
+ @unittest.skipIf(USING_PTHREAD_COND,
+ 'POSIX condition variables cannot be interrupted')
def test_rlock_acquire_interruption(self):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.