To avoid explicit sys.stdout.flush() statements, one should use python3 -u script.py which explicitly flush all print statements for the standard streams.
sys.stdout.flush()
python3 -u script.py
Keywords: python python3 patterns design tricks trade flush nohup