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
Post a Comment