Skip to content Skip to sidebar Skip to footer

PyInstaller Unbuffered Stdio

Problem Docker image sizes should commonly be as small as possible. Using full-blown environments like a standard python image results often, with all dependencies installed, in he

Solution 1:

At least it is broken on Windows (See issue on github) and it’s not in the docs.


Solution 2:

This pull request fixed the issue.

The '-u' option will set the Py_UnbufferedStdioFlag flag to enable unbuffered stdio mode in Python library.

This doc shows how to enable the runtime option with spec file.

options = [ ('u', None, 'OPTION') ]
a = Analysis( ...
        )
...
exe = EXE(pyz,
  a.scripts,
  options,   <--- added line
  exclude_binaries=...
  )

NOTE:

This enables unbuffered binary layer of stdout and stderr streams in all supported Python versions, while unbuffered text layer requires Python 3.7 or later.


Post a Comment for "PyInstaller Unbuffered Stdio"