Python中进程间通信出现(PermissionError: [WinError 5] 拒绝访问。)
作者:互联网
from multiprocessing import Process,Queue
import os,time
def write(q):
print("启动写子进程%s" % (os.getpid()))
for chr in ["A","B","C","D"]:
q.put(chr)
time.sleep(1)
print("结束写子进程%s" % (os.getpid()))
def read(q):
print("启动读子进程%s" % (os.getpid()))
while True:
value=q.get(True)
print("value="+value)
print("结束读子进程%s" % (os.getpid()))
if __name__=="__main__":
q=Queue()
pw = Process(target=write,args=(q,))
pr = Process(target=read, args=(q,))
pw.start()
pr.start()
pw.join()
#pr进程是死循环,强行结束
pr.terminate()
print("结束父进程")
程序出现这问题,各种尝试还没解决
PermissionError: [WinError 5] 拒绝访问。
标签:WinError,__,Python,pr,间通信,进程,getpid,print,os 来源: https://www.cnblogs.com/zlong123/p/10540009.html