I'm trying to pipe the output of a python script using os.popen() . Here my python script :
sample.py
while(True):
print("hello")
python version : 3.6.7 os : ubuntu 18.04
My script to do the process :
import os
import types
def sample_function():
pipe = os.popen('python3 /home/gomathi/sample.py')
while(True):
a = pipe.readline()
yield a
s=sample_function()
for i in s:
print(i)
It works well for the above code.Now the problem is , i have changed the sample.py as follows :
sample.py
print("hello")
It just print blank for the entire screen and continues printing blank characters . What went wrong with my code ? What changes to be made in my code to work for the above sample.py ?