0

I have an executable python script, process-data.py that reads live input through stdin and processes it in real time. I want to feed it two types of data: images, and raw text. both are generated from other python scripts.

processing text works when using unbuffer and a pipe like so:

unbuffer ./text-output.py | ./process-data.py

doing the same for the image data also works

unbuffer ./image-output.py | ./process-data.py

How would I run both image-output.py and text-output.py at the same time and process the data without a delay from a buffer? I have tried using cat, but it doesn't work in real time (both "output" scripts generate their data over time and do so indefinitely)

bjubes
  • 195
  • 1
  • 15
  • How will the receiving script know what is what on its input channel? How can it distinguish images from text when they are all interleaved? – Mark Setchell Mar 23 '18 at 21:55
  • @MarkSetchell Yes, the program is capable of discerning the difference. It knows the syntax of the text data and the image-output prefixes images with a special character sequence – bjubes Mar 23 '18 at 23:28

1 Answers1

0

You can try to use named pipes:

mkfifo /tmp/pipe
./text-output.py > /tmp/pipe &
./image-output.py > /tmp/pipe &
./process-data.py < /tmp/pipe
rm /tmp/pipe

But remember, that pipes (named and unnamed) still use buffers inside.

P. Dmitry
  • 1,123
  • 8
  • 26
  • Is there a way to use unbuffer with named pipes? The real time aspect is especially important. – bjubes Mar 23 '18 at 23:29