Closed lukas-vlcek closed 7 years ago
Yes, there should be an unbuffered output option for watches, for exactly this use case.
You can also use the stdbuf
command when running commands from the shell:
$ stdbuf -o 0 watches cluster_health -i 1 -d 30 -l >> ${log_file}
After discussing it with @richm we can also add new option to do unbuffered in python code using:
import os
import sys
unbuffered = os.fdopen(sys.stdout.fileno(), 'w', 0)
sys.stdout = unbuffered
When redirecting
watches
output to a file, i.e.:then the content in the file
${log_file}
appears after thewatches
command finished (in this example after 30 seconds). I am not sure if there are any benefits for production use but at least for testing this is not practical. I would like to be able totail -f ${log_file}
right away and see content in the real-time.If I understand correctly this could be solved by forcing unbuffered output for python. See http://stackoverflow.com/questions/107705/disable-output-buffering.
@richm WDYT?