[Python-Dev] [Python-checkins] cpython: Issue #15794: Relax a test case due to the deadlock detection's (original) (raw)
Brett Cannon brett at python.org
Tue Aug 28 21:00:57 CEST 2012
- Previous message: [Python-Dev] Sphinx issue in What's New in Python 3.3 doc
- Next message: [Python-Dev] cpython: Issue #15794: Relax a test case due to the deadlock detection's
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Should there be a Misc/NEWS entry since we are in rc mode?
On Tue, Aug 28, 2012 at 2:13 PM, antoine.pitrou <python-checkins at python.org>wrote:
http://hg.python.org/cpython/rev/454dceb5fd56 changeset: 78790:454dceb5fd56 parent: 78788:06497bbdf4fe user: Antoine Pitrou <solipsis at pitrou.net> date: Tue Aug 28 20:10:18 2012 +0200 summary: Issue #15794: Relax a test case due to the deadlock detection's conservativeness.
files: Lib/test/testimportlib/testlocks.py | 22 ++++++++++++-- 1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/Lib/test/testimportlib/testlocks.py b/Lib/test/testimportlib/testlocks.py --- a/Lib/test/testimportlib/testlocks.py +++ b/Lib/test/testimportlib/testlocks.py @@ -1,4 +1,5 @@ from importlib import bootstrap +import sys import time import unittest import weakref @@ -41,6 +42,17 @@ @unittest.skipUnless(threading, "threads needed for this test") class DeadlockAvoidanceTests(unittest.TestCase): + def setUp(self): + try: + self.oldswitchinterval = sys.getswitchinterval() + sys.setswitchinterval(0.000001) + except AttributeError: + self.oldswitchinterval = None + + def tearDown(self): + if self.oldswitchinterval is not None: + sys.setswitchinterval(self.oldswitchinterval) + def rundeadlockavoidancetest(self, createdeadlock): NLOCKS = 10 locks = [LockType(str(i)) for i in range(NLOCKS)] @@ -75,10 +87,12 @@ def testdeadlock(self): results = self.rundeadlockavoidancetest(True) - # One of the threads detected a potential deadlock on its second - # acquire() call. - self.assertEqual(results.count((True, False)), 1) - self.assertEqual(results.count((True, True)), len(results) - 1) + # At least one of the threads detected a potential deadlock on its + # second acquire() call. It may be several of them, because the + # deadlock avoidance mechanism is conservative. + nbdeadlocks = results.count((True, False)) + self.assertGreaterEqual(nbdeadlocks, 1) + self.assertEqual(results.count((True, True)), len(results) - nbdeadlocks) def testnodeadlock(self): results = self.rundeadlockavoidancetest(False) -- Repository URL: http://hg.python.org/cpython
Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120828/f557eb62/attachment-0001.html>
- Previous message: [Python-Dev] Sphinx issue in What's New in Python 3.3 doc
- Next message: [Python-Dev] cpython: Issue #15794: Relax a test case due to the deadlock detection's
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]