I am starting a new process and redirecting its stdout to a text file. I am want to read the progress the processing from the file, however the file stays empty until the process finishes executing. Can you explain this behavior and if there is a work around it ?
p = Process(target=foo, args=(a,))
p.start()
def foo(a):
sys.stdout = open(str(os.getpid()) + ".out", "w")
print("test")
time.sleep(10)