[ python multiprocessing.Pipe 多进程管道的使用 ] 三种常见报错
from multiprocessing import Pipe
sed, rec = Pipe()
# 依次发送两条数据
sed.send([1111])
sed.send([1112])
1,如果管道-发送端 关闭了,接收端还去接收的话,会在接收完管道中残存的数据之后,报EOF的错误:raise EOFError
sed.close() # 管道-发送端关闭
while True:
c = rec.recv() # 管道-接收端接收
print(c)
# 输出
[1111]
[1112]
Traceback (most recent call last):
File "C:\Users\user1\AppData\Local\Programs\Python\Python38\lib\multiprocessing\connection.py", line 301, in _recv_bytes
ov, err = _winapi.ReadFile(self._handle, bsize,
BrokenPipeError: [WinError 109] 管道已结束。
During handling of the above excepti