【发布时间】:2015-11-13 15:35:31
【问题描述】:
我使用python3.4的os.pipe做IPC betwen的父进程和子进程, 通过 os.execlp args 传递管道参数
self.child_pipe_read=int(sys.argv[2])
self.child_pipe_write=int(sys.argv[3])
...
os.execlp('python3','python3','child_test.py',str(pid),str(self.child_pipe_read) ,str(self.child_pipe_write))
但是,当我使用这个时:
msg=os.read(self.child_pipe_read,32)
抛出错误 OSError: [Errno 9] 错误的文件描述符
然后我尝试写入管道:
os.write(self.parent_pipe_write,(msg+'\n').encode())
BrokenPipeError: [Errno 32] 损坏的管道
我看到了python3.4的文档,找到这个:
“3.4 版更改:新文件描述符现在不可继承” 但我不知道这是什么意思? 如何使用管道进行 IPC?
【问题讨论】:
-
您的代码甚至没有显示管道创建。请添加它。另外,请参阅如何create a minimal, verifiable example 以获取有关最大化您将获得的答案的有用性的提示。