MCPcopy Index your code
hub / github.com/python/cpython / run

Method run

Lib/test/test_threading.py:86–108  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

84 self.nrunning = nrunning
85
86 def run(self):
87 delay = random.random() / 10000.0
88 if verbose:
89 print('task %s will run for %.1f usec' %
90 (self.name, delay * 1e6))
91
92 with self.sema:
93 with self.mutex:
94 self.nrunning.inc()
95 if verbose:
96 print(self.nrunning.get(), 'tasks are running')
97 self.testcase.assertLessEqual(self.nrunning.get(), 3)
98
99 time.sleep(delay)
100 if verbose:
101 print('task', self.name, 'done')
102
103 with self.mutex:
104 self.nrunning.dec()
105 self.testcase.assertGreaterEqual(self.nrunning.get(), 0)
106 if verbose:
107 print('%s is finished. %d tasks are running' %
108 (self.name, self.nrunning.get()))
109
110
111class BaseTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 7

assertLessEqualMethod · 0.80
assertGreaterEqualMethod · 0.80
randomMethod · 0.45
incMethod · 0.45
getMethod · 0.45
sleepMethod · 0.45
decMethod · 0.45

Tested by

no test coverage detected