Here is my code below , I put string in queue , and hope dowork2 to do something work , and return char in shared_queue
but I always get nothing at while not shared_queue.empty()
please give me some point , thanks.
import time import multiprocessing as mp class Test(mp.Process): def __init__(self, **kwargs): mp.Process.__init__(self) self.daemon = False print('dosomething') def run(self): manager = mp.Manager() queue = manager.Queue() shared_queue = manager.Queue() # shared_list = manager.list() pool = mp.Pool() results = [] results.append(pool.apply_async(self.dowork2,(queue,shared_queue))) while True: time.sleep(0.2) t =time.time() queue.put('abc') queue.put('def') l = '' while not shared_queue.empty(): l = l + shared_queue.get() print(l) print( '%.4f' %(time.time()-t)) pool.close() pool.join() def dowork2(queue,shared_queue): while True: path = queue.get() shared_queue.put(path[-1:]) if __name__ == '__main__': t = Test() t.start() # t.join() # t.run()