是什么导致了多处理队列的此权限错误?



我一直在探索一个项目的队列、管道等。

以下代码用于了解队列的操作方式:

from multiprocessing import Process, Queue
def words(liss, q):
newlis = []
for i in liss:
# newlis.append(str(i) + "flag")
q.put(str(i) + "flag")
def reading(q):
while not q.empty():
print(q.get())

if __name__ == '__main__':
q = Queue()
p1 = Process(target=words, args=([23, "Hello", "Hey", 78], q))
p2 = Process(target=readit, args=(q,))
p1.start()
p2.start()
p1.join()
p1.join()

我尝试更改我放入队列的内容并以更高的权限运行程序。两者都遇到了此错误:

Process Process-1:
Traceback (most recent call last):
File "C:UsersJonatAppDataLocalProgramsPythonPython37-32libmultiprocessingprocess.py", line 297, in _bootstrap
self.run()
File "C:UsersJonatAppDataLocalProgramsPythonPython37-32libmultiprocessingprocess.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "C:UsersJonatPycharmProjectsGiraffeSmall-Tests.py", line 8, in words
q.put(liss)
File "C:UsersJonatAppDataLocalProgramsPythonPython37-32libmultiprocessingqueues.py", line 82, in put
if not self._sem.acquire(block, timeout):
PermissionError: [WinError 5] Access is denied
Process finished with exit code 0

我找到了另一个关于此错误的帖子,但我不太明白。无论如何,我将在此处链接该帖子:此错误的原因是什么:"PermissionError: [WinError 5] 访问被拒绝">

由@DipenShah解决。

这是 Python 3.7.2 的已知问题 升级或降级到其他版本应该可以修复它。

相关内容

  • 没有找到相关文章