git hooks server side output only transmits on a newline. I want to configure a custom task and print real-time output on the same line. How can I achieve that? I tried sys.stdout.flush but it transmits everything once complete. It does work in real-time if I add a newline. I want something like
Step A)Started......Completed
with each '.' appended after a given time.
My current code looks like the following and it outputs only when the method is completed.
import sys, time, os
def print_realtime():
sys.stdout.write('Started.')
sys.stdout.flush()
time.sleep(1)
for i in range(1, 15):
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(0.5)
if __name__ == "__main__":
print_realtime()
However, it works in realtime if I append '\n' like:
sys.stdout.write('.\n')