Unbuffered Python
This article discusses the process of unbuffering Python’s stdout output by utilizing the ‘-u’ option when running a script and modifying the print function to flush output. Additionally, it covers the use of asyncio.create_subprocess_exec for asynchronous reading.
When reading bytes asynchronously from stdout
using asyncio.create_subprocess_exec
, the program has to be unbuffered.
1 | python3 -u <script_path> |
1 | # this can only make `print` into unbuffered |