I run an external exe from python3 that redirects to file
import subprocess
subprocess.Popen('app.exe > out.txt', shell=True, stdout=sub.PIPE)
but after, when I check if it's created sometimes it says no, but file is actually there:
assert exists('out.txt') and isfile('out.txt')
I suspect there is some buffering going on, how can I flush it to disk?
sys.stdout.flush()
didn't help. Adding artificial delays is too hacky. Using win10.