MCPcopy Create free account
hub / github.com/ActiveState/code / test1

Function test1

recipes/Python/576418_Multithreaded_FIFO_Gate/recipe-576418.py:198–229  ·  view source on GitHub ↗

Test code where gate is closed successfully

()

Source from the content-addressed store, hash-verified

196
197
198 def test1():
199 """ Test code where gate is closed successfully """
200
201 print 'test1()...'
202
203 gate = ThreadGate(10, 20)
204
205 random.seed()
206
207 print 'Starting threads...'
208 # Create 10 threads
209 threads = []
210 threads.append(OwnerThread(gate))
211
212 for x in range(10):
213 threads.append(SampleThread(x, gate))
214
215 # Start threads and join
216 for x in range(11):
217 threads[x].start()
218
219
220 # Join with threads
221 for x in range(11):
222 threads[x].join()
223
224 print 'Joined with threads'
225 print 'Gate count=>',gate.get_count()
226
227 # Exit and entry logs must be same
228 print enterlog
229 print exitlog
230
231 def test2():
232 """ Test code where gate is closed unsuccessfully """

Callers 1

testFunction · 0.70

Calls 9

get_countMethod · 0.95
ThreadGateClass · 0.85
OwnerThreadClass · 0.85
rangeFunction · 0.85
SampleThreadClass · 0.85
seedMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected