1

While I am writing some python-scripts, which filter output from an other program which is piped into the script, I only want to flush the output, when the input-program also has flushed its output. However, the script do not always read whole lines. The output should directly occur after it is progressed by the script and then it should sleep, when the input-program progresses. How to efficiently implement this behavior, that the next program in the pipeline can directly work with the progressed output of the program before the script in the pipeline?

cmdLP
  • 1,658
  • 9
  • 19
  • Without some form of tracing/debugging, the process on one end of a pipeline has no way of knowing when the process on the other end calls any sort of `flush()` routine. It can only tell "there's new data to read" or "there's no data available at this time", or "the pipe has gone away". – twalberg Aug 04 '17 at 16:05
  • However, I used to check, if it is not flushed by ``kbhit()`` (or some implementation like it), but it sometimes returns false, so a flush occurs, while it is not flushed by the input. – cmdLP Aug 04 '17 at 16:08

0 Answers0