python --help
returns:
-u : force the stdout and stderr streams to be unbuffered;
this option has no effect on stdin; also PYTHONUNBUFFERED=x
So I put on start of my main.py
:
if __name__ == '__main__':
os.environ['PYTHONUNBUFFERED'] = 'x'
Why my prints are not being flushed?
The behavior is different when I use python -u main.py
. This second situation flush every single print, even the ones inside packages, and tha'ts what I want.