Python Multiprocessing Example – JournalDev

from multiprocessing import Queuecolors = [‘red’, ‘green’, ‘blue’, ‘black’]cnt = 1# instantiating a queue objectqueue = Queue()print(‘pushing items to queue:’)for color in colors: print(‘item no: ‘, cnt, ‘ ‘, color) queue.put(color) cnt += 1print(‘\npopping items from queue:’)cnt = 0while not queue.empty(): print(‘item no: ‘, cnt, ‘ ‘, queue.get()) cnt += 1

Source : Python Multiprocessing Example – JournalDev