diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-29 05:06:52 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-29 05:06:52 (GMT) |
commit | ca67412f282c8e821b27097aa812f582e6f2b13f (patch) | |
tree | 4b1a4e12accec0f8aaee25f847cea98f6c7ebc63 /Lib | |
parent | 34465e7ec659441a2f7ec936475b8433d629fbeb (diff) | |
download | cpython-ca67412f282c8e821b27097aa812f582e6f2b13f.zip cpython-ca67412f282c8e821b27097aa812f582e6f2b13f.tar.gz cpython-ca67412f282c8e821b27097aa812f582e6f2b13f.tar.bz2 |
Update test_threading with a couple changes from trunk that got lost due, I
presume, to merge conflicts.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_threading.py | 10 |
1 files 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() |