I have problems of reading with python from stdin
if I have a pipe with continuous data stream which doesn't stop.
As an example I have data_stream.py
import time
i = 0
while True:
print(i)
i += 1
time.sleep(2)
Now I try to read the data with the file read_data.py
import sys
for line in sys.stdin:
print(line)
When I try to run it with python3 data_stream.py | python3 read_data.py
I get no result because data_stream.py
did not finished.
How can I read from data_stream.py
while it is still running?