Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Python in non-buffered mode #11

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

alukach
Copy link
Member

@alukach alukach commented Aug 9, 2024

What I'm changing

I've been noticing that there are times when my log statements or print statements are not visible in a python-based docker compose service's output until I close/restart the service. This is because Python buffers its stdout by default.

How I did it

Run services with PYTHONBUFFERED=1 env var, which is akin to python -u .... As described in the docs:

Force the stdout and stderr streams to be unbuffered. This option has no effect on the stdin stream.

With this enabled, logs and print statements are made immediately available in the docker compose output.

@alukach alukach requested a review from vincentsarago August 9, 2024 23:09
@alukach alukach merged commit c79692c into main Aug 12, 2024
1 check passed
@alukach alukach deleted the chore/disable-python-buffering branch August 12, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants