threads and concurrency of generator or produced in some other manner sequence [ , , , producer(sequenceqwait for all items to be processed join(in this examplethe consumer process is set to daemonic because it runs forever and we want it to terminate when the main program finishes (if you forget thisthe program will hanga joinablequeue is being used so that the producer actually knows when all of the items put in the queue have been successfully processed the join(operation ensures thisif you forget this stepthe consumer will be terminated before it has had time to complete all of its work if desiredmultiple processes can put and get items from the same queue for exampleif you wanted to have pool of consumer processesyou could just write code like thisif _name_ =' _main_ ' multiprocessing joinablequeue(launch some consumer processes cons_p multiprocessing process(target=consumer,args=( ,)cons_p daemon=true cons_p start(cons_p multiprocessing process(target=consumer,args=( ,)cons_p daemon=true cons_p start(produce items sequence represents sequence of items to be sent to the consumer in practicethis could be the output of generator or produced in some other manner sequence [ , , , producer(sequenceqwait for all items to be processed join(when writing code such as thisbe aware that every item placed into the queue is pickled and sent to the process over pipe or socket connection as general ruleit is better to send fewer large objects than many small objects in certain applicationsa producer may want to signal consumers that no more items will be produced and that they should shut down to do thisyou should write code that uses sentinel-- special value that indicates completion here is an example that illustrates this concept using none as sentinelimport multiprocessing def consumer(input_q)while trueitem input_q get(if item is nonebreak process item print(itemreplace with useful work shutdown print("consumer done"def producer(sequenceoutput_q)for item in sequencef lib fl ff