python - How to make os.mkfifo and subprocess.Popen work together? -


i'm trying redirect patch command output using named pipe. tried this:

fifo = os.path.join(self.path, 'pipe') os.mkfifo(fifo) op = os.popen('cat '+ fifo) proc = popen(['patch', current_keyframe, '--input='+fpath, '--output='+fifo], stdin=pipe, stdout=pipe) os.unlink(fifo) print op.read() 

but script stops @ popen() call patch command didn't completed. how can make work properly?

you aren't waiting patch command finish before read fifo. replace subprocess.popen() call subprocess.call(), , remove stdin/stdout redirections aren't using. also, use open(fifo) read fifo, not os.popen('cat ' + fifo).

you realize, hope, can avoid fifo entirely? after p = popen(['patch', '--input', fpath], stdout=pipe), can read patch's output p.stdout.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -