Write a simple python script test.py:
import time
print "begin"
time.sleep(10)
print "stop"
In bash, run
python test.py > log.txt
What I observe is that both "begin" and "stop" appear in log.txt at the same time, after 10 seconds.
Is this expected behavior?
Have you tried calling python with the -u option, which "forces stdin, stdout and stderr to be totally unbuffered" =>
python -u test.py > log.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With