小编T_M*_*Mac的帖子

python命名管道问题

我正在尝试使用命名管道在守护程序和客户端之间建立双向通信.代码在尝试打开用于输入的命名管道时挂起为什么?

class comm(threading.Thread):

def __init__(self):
    self.srvoutf = './tmp/serverout'
    self.srvinf = './tmp/serverin'
    if os.path.exists(self.srvoutf):
        self.pipein = open(self.srvoutf, 'r') 
        #-----------------------------------------------------Hangs here
    else:
        os.mkfifo(self.srvoutf)
        self.pipein = open(self.srvoutf, 'r')
        #-----------------------------------------------------or here
    if os.path.exists(self.srvinf):
        self.pipeout = os.open(self.srvinf, os.O_WRONLY)
    else:
        os.mkfifo(self.srvinf)
        self.pipeout = os.open(self.srvinf, os.O_WRONLY)

    threading.Thread.__init__ ( self )
Run Code Online (Sandbox Code Playgroud)

python

10
推荐指数
1
解决办法
7428
查看次数

标签 统计

python ×1