How to pipe two seperate outputs into a single program's input without a buffer

37 Views Asked by At

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)

1

There are 1 best solutions below

1
P. Dmitry On

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.