[英]PermissionError: [Errno 1] Operation not permitted in Python while reading after write
I encountered following problem while writing my program: I have binary file, via which 2 processes are communicating, one of them is my python program. 我在编写程序时遇到以下问题:我有一个二进制文件,通过它进行2个进程的通信,其中之一是我的python程序。 I open file with os: 我用os打开文件:
self.io_file = os.open(med_file, os.O_RDWR)
so I can read it binary. 所以我可以读二进制。 I read content of the file, then try to write answer into the same file (I'm at the end of file, of course). 我读取了文件的内容,然后尝试将答案写到同一文件中(当然,我在文件末尾)。 Everything's alright up until I try to read again (new question) after this write. 一切都很好,直到我写完这篇文章再试一次(新问题)。 Then following happens: 然后发生以下情况:
Traceback (most recent call last):
File "/home/ydenko/program.py", line 172, in read
return os.read(self.io_file, msg_size)
PermissionError: [Errno 1] Operation not permitted
I find it curious that up until I write something, everything works flawlessly. 我感到奇怪的是,直到我写点东西,一切都完美无瑕。 Any idea why this happens? 知道为什么会这样吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.