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

Function main

recipes/Python/475216_Bounded_Buffer_Example_1/recipe-475216.py:24–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22
23# provides an outline for the execution of the program
24def main():
25 # check and parse the command line arguments
26 parse_sys_argv()
27 # setup the variables used by the threads
28 run_flag = [True]
29 queue = Queue(argv[1])
30 send = Stack()
31 recv = Stack()
32 # start the threads
33 producer = Thread(target=produce, args=(run_flag, queue, send))
34 consumer = Thread(target=consume, args=(run_flag, queue, recv, producer))
35 producer.start()
36 consumer.start()
37 # let the threads do their work
38 sleep(argv[2])
39 run_flag[0] = False
40 consumer.join()
41 # verify that the solution was valid
42 calculate_results(send, recv)
43
44# parses and checks the command line arguments
45def parse_sys_argv():

Callers 1

recipe-475216.pyFile · 0.70

Calls 8

parse_sys_argvFunction · 0.85
sleepFunction · 0.85
calculate_resultsFunction · 0.85
StackClass · 0.70
QueueClass · 0.50
ThreadClass · 0.50
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected