Why doesn't Queue work?
from multiprocessing import Process, Queue import os, time, random def write(q): print ('Process to write: %s' % os.getpid()) a=33 q.put(a) def read(q): # It seems that the function doesn't work print ('Process to read: %s' % os.getpid()) while True: value = q.get(True) print ('Get %s from queue.' % value)
if __name__=='__main__': q = Queue() pw = Process(target=write, args=(q,)) p r = Process(target=read, args=(q,)) pw.start() pr.start() pw.join() pr.terminate() print ('done')
Process to write: 1880 done