python多个并发fifo

时间:2018-08-01 15:37:17

标签: python

如何使用Python3打开多个fifo? 下面的代码非常简单,但是它在最后一行堆叠并等待(?)... 请帮忙吗?

   toAgent = ['ABCD', 'EFGH', 'IJKL', 'MNOP',]

   def createPipe():

        for i in range(0, len(toAgent)):
            #print(i)
            fifoName = '../tmp/' + toAgent[i]       
            if not os.path.exists(fifoName):
                os.mkfifo(fifoName) 

                pipeName = 'pipe_' + str(i)
                print(pipeName, fifoName)
                pipeName = os.open(fifoName, os.O_WRONLY )

1 个答案:

答案 0 :(得分:0)

import os
toAgent = ['ABCD', 'EFGH', 'IJKL', 'MNOP',]

def createPipe():
    for i in range(0, len(toAgent)):
            #print(i)
        fifoName = '../tmp/' + toAgent[i]
        if not os.path.exists(fifoName):
            os.mkfifo(fifoName)

            pipeName = 'pipe_' + str(i)
            print(pipeName, fifoName)
            pipeName = os.open(fifoName, os.O_WRONLY )

createPipe()