What is the environment variable Python in PYTHONUNBUFFERED for?

The following is a common dockerfile , in which there is a line of ENV PYTHONUNBUFFERED 1 , I added it all without a brain, but I don't know what the consequences will be if I don't add it!

FROM python:3.9-buster
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN (/usr/local/bin/python -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple) && (pip install -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt)
COPY . /code/

Read and this article: Python Environment Variables PYTHONUNBUFFERED

For versions above 3.7: standard output stdout and standard error stderr are all unbuffered
Changed in version 3.7: The text layer of the stdout and stderr streams now is unbuffered.

As long as it is version > 3.7 , there is no need to add PYTHONUNBUFFERED


universe_king
3.4k 声望680 粉丝