Skip to content
Discussion options

You must be logged in to vote

Ah, this is a very common issue! I really should just write a wiki article about this... 😝

Many languages, Python included, will BUFFER standard output until either the buffer entirely fills up, or the process exits. You will need to bypass stdout buffering in your script for things like live progress updates. There are a number of ways to do this with Python:

Flush in code (most common)

Explicit flush:

print("Hello", flush=True)

Manual flush:

import sys

print("Hello")
sys.stdout.flush()

Disable buffering for the entire process (CLI)

Enable -u (unbuffered mode):

python -u script.py

Control buffering via environment variables

PYTHONUNBUFFERED=1 python script.py

Change buffering behavior i…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by arminus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants