I am currently calling an external c++ program which generates a lot output by using subprocess.check_output, and save the stdout into a log file. However c++ program may take very long time to finish, but I want to view the stdout before it finished, just like if I directly execute the c++ program via bash command line.
Of course, I may accomplish this by directly modifying my c++ program using fstream to save the output. But I wonder if there's any solution in python which can intercept the stdout.
Thank you in advance!