Pipe進程之間的通訊

#_author:來童星
#date:2019/12/11
#Pipe
from multiprocessing import Process, Pipe
def f(conn):
conn.send([42, None, 'hello'])
conn.close()
if __name__ == '__main__':
parent_conn, child_conn = Pipe()
p = Process(target=f, args=(child_conn,))
p.start()
print(parent_conn.recv()) #[42, None, 'hello']
    p.join()運行結果:[42, None, 'hello']
相關文章
相關標籤/搜索