When I use subprocess.run
with capture_output=True
, I notice that the output is not in real time. As example, the following script will wait till ping is completed, then it will display the output.
import subprocess
out = subprocess.run(['ping', '-c', '3', '127.0.0.1'], capture_output=True, text=True)
print(out.stdout)
I don't have this problem without capture_output=False
out = subprocess.run(['ping', '-c', '3', '127.0.0.1'], text=True)
Would it be possible to make it in real time with capture_output=True
?
Imagine if I change it to 'ping', '-c', '100'
, I've to wait it like forever in order to see the output.
If subprocess.run
is not the right tool to achieve this, please let me know the alternative.