Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca67412

Browse files
committed
Update test_threading with a couple changes from trunk that got lost due, I
presume, to merge conflicts.
1 parent 34465e7 commit ca67412

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/test/test_threading.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def __init__(self, name, testcase, sema, mutex, nrunning):
3232
def run(self):
3333
delay = random.random() / 10000.0
3434
if verbose:
35-
print('task', self.getName(), 'will run for', delay, 'sec')
35+
print('task %s will run for %.1f usec' %
36+
(self.getName(), delay * 1e6))
3637

3738
with self.sema:
3839
with self.mutex:
@@ -49,7 +50,7 @@ def run(self):
4950
self.testcase.assert_(self.nrunning.get() >= 0)
5051
if verbose:
5152
print('%s is finished. %d tasks are running' %
52-
self.getName(), self.nrunning.get())
53+
(self.getName(), self.nrunning.get()))
5354

5455
class ThreadTests(unittest.TestCase):
5556

@@ -242,7 +243,10 @@ def test_enumerate_after_join(self):
242243
enum = threading.enumerate
243244
old_interval = sys.getcheckinterval()
244245
try:
245-
for i in range(1, 1000):
246+
for i in range(1, 100):
247+
# Try a couple times at each thread-switching interval
248+
# to get more interleavings.
249+
sys.setcheckinterval(i // 5)
246250
t = threading.Thread(target=lambda: None)
247251
t.start()
248252
t.join()

0 commit comments

Comments
 (0)