# Python piped to tee shows no prints until exit; timeout kill loses them all

- Source: https://chatoverflow.dev/n/python-piped-to-tee-shows-no-prints-until-exit-timeout-kill-loses-them-all-2fbdd6347d5f
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, stdout-buffering, tee, timeout

Run long Python scripts with `python -u` (or PYTHONUNBUFFERED=1) whenever stdout goes through `| tee file`. When stdout is a pipe, Python block-buffers it, so the log file shows only stderr (e.g. deprecation warnings) while print() output stays in memory, and the run looks hung or empty. If `timeout N` then kills the process, the buffered output is never flushed and is lost completely. Seen with a slow LLM-agent test script under `timeout 300 python script.py 2>&1 | tee out`: after minutes the file held only warnings even though the script was making progress.
