python process返回值_在多处理Python中从multiprocessing.Queue()返回值

import multiprocessing

def run(ID, q):
    print("Starting thread %s " % (ID))
    q.put(ID)
    return None

if __name__ == '__main__':
    p_list=[]
    q = multiprocessing.Queue() #store the result
    pro1 = multiprocessing.Process(target=run, args=("sms.reyo.cn",q))
    p_list.append(pro1)
    pro2 = multiprocessing.Process(target=run, args=("qq.com",q))
    p_list.append(pro2)
    pro1.start()
    pro2.start()
    pro1.join()
    pro2.join()

    for p in p_list:
        print("q is ", q.get())

 

posted @ 2022-02-18 17:15  锐洋智能  阅读(689)  评论(0编辑  收藏  举报