[Python-checkins] cpython (merge 3.2 -> default): Merge commit for #11233
antoine.pitrou
python-checkins at python.org
Sun Mar 13 19:16:11 CET 2011
http://hg.python.org/cpython/rev/f197dac00f43
changeset: 68422:f197dac00f43
parent: 68418:e34b09c69dd3
parent: 68421:5d0d488cbca8
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Mar 13 19:16:03 2011 +0100
summary:
Merge commit for #11233
files:
Misc/NEWS
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -73,18 +73,29 @@
def test_lock_acquire_interruption(self):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
try:
lock = thread.allocate_lock()
lock.acquire()
signal.alarm(1)
- self.assertRaises(KeyboardInterrupt, lock.acquire)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5)
+ dt = time.time() - t1
+ # Checking that KeyboardInterrupt was raised is not sufficient.
+ # We want to assert that lock.acquire() was interrupted because
+ # of the signal, not that the signal handler was called immediately
+ # after timeout return of lock.acquire() (which can fool assertRaises).
+ self.assertLess(dt, 3.0)
finally:
signal.signal(signal.SIGALRM, oldalrm)
def test_rlock_acquire_interruption(self):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
try:
rlock = thread.RLock()
@@ -98,7 +109,11 @@
rlock.release()
time.sleep(0.01)
signal.alarm(1)
- self.assertRaises(KeyboardInterrupt, rlock.acquire)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5)
+ dt = time.time() - t1
+ # See rationale above in test_lock_acquire_interruption
+ self.assertLess(dt, 3.0)
finally:
signal.signal(signal.SIGALRM, oldalrm)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -188,6 +188,9 @@
Tests
-----
+- Issue #11223: Fix test_threadsignals to fail, not hang, when the
+ non-semaphore implementation of locks is used under POSIX.
+
- Issue #10911: Add tests on CGI with non-ASCII characters. Patch written by
Pierre Quentel.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list