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

Function test2

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

Test code where gate is closed unsuccessfully

()

Source from the content-addressed store, hash-verified

229 print exitlog
230
231 def test2():
232 """ Test code where gate is closed unsuccessfully """
233
234 print 'test1()...'
235
236 gate = ThreadGate(10, 5)
237
238 random.seed()
239
240 print 'Starting threads...'
241 # Create 10 threads
242 threads = []
243 threads.append(OwnerThread(gate))
244
245 for x in range(10):
246 threads.append(SampleThread(x, gate))
247
248 # Start threads and join
249 for x in range(11):
250 threads[x].start()
251
252
253 # Join with threads
254 for x in range(11):
255 threads[x].join()
256
257 print 'Joined with threads'
258
259 print 'Gate count=>',gate.get_count()
260
261 # Exit and entry logs must be same
262 print enterlog
263 print exitlog
264
265 test1()
266

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