From ca67412f282c8e821b27097aa812f582e6f2b13f Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Sat, 29 Mar 2008 05:06:52 +0000 Subject: Update test_threading with a couple changes from trunk that got lost due, I presume, to merge conflicts. --- Lib/test/test_threading.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index ee0b197..3508bfc 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -32,7 +32,8 @@ class TestThread(threading.Thread): def run(self): delay = random.random() / 10000.0 if verbose: - print('task', self.getName(), 'will run for', delay, 'sec') + print('task %s will run for %.1f usec' % + (self.getName(), delay * 1e6)) with self.sema: with self.mutex: @@ -49,7 +50,7 @@ class TestThread(threading.Thread): self.testcase.assert_(self.nrunning.get() >= 0) if verbose: print('%s is finished. %d tasks are running' % - self.getName(), self.nrunning.get()) + (self.getName(), self.nrunning.get())) class ThreadTests(unittest.TestCase): @@ -242,7 +243,10 @@ class ThreadTests(unittest.TestCase): enum = threading.enumerate old_interval = sys.getcheckinterval() try: - for i in range(1, 1000): + for i in range(1, 100): + # Try a couple times at each thread-switching interval + # to get more interleavings. + sys.setcheckinterval(i // 5) t = threading.Thread(target=lambda: None) t.start() t.join() -- cgit v0.12