下面是源代码,我想问下为什么管道通信不成功
import time
from multiprocessing import Process, Pipe
import threading
def f3(conn_1,conn_2):
thread0 = threading.Thread(target=f, args=(conn_1,conn_2,))
thread0.setDaemon(True)
thread0.start()
def f(conn_1,conn_2):
conn_2.close()
conn_1.send(1)
conn_1.close()
def f1(conn_1,conn_2):
conn_1.close()
print("Conn_2: ", conn_2.recv())
conn_2.close()
if __name__ == '__main__':
conn_1, conn_2 = Pipe() # 生成管道的两边,分别传给两个进程
p = Process(target=f3, args=(conn_1,conn_2))
p.start()
thread0 = threading.Thread(target=f1, args=(conn_1,conn_2,))
thread0.setDaemon(True)
thread0.start()