Mon. Mar 2nd, 2026

By default, Python buffers its output, meaning that printed data may not appear immediately. This can sometimes cause delays in logs, especially in environments like Docker or when output is being redirected. If you need immediate output, you can disable buffering by using the -u option when running Python, setting the PYTHONUNBUFFERED=1 environment variable, or adding flush=True to your print() statements.

PYTHONUNBUFFERED=1 python script.py

Or

python -u script.py