'Python console may not show new print until resized

I am making a Python pyinstaller executable with a console on Windows that prints new output and once in a while asks for input from user, however sometimes when the user does not have the console in focus the console does not print the new output until the user resizes it or presses some input. I have a video showcasing it here: https://cdn.discordapp.com/attachments/486190714863222784/950152317108387860/2022-03-06_17-05-27.mp4

Points of note:

Using os.system('mode con: cols=80 lines=40') to resize the window, not sure if related.

It doesn't always happen, in fact the above video it took me some 20 tries to get it to be reproduced.

Source code can be found here: https://github.com/Evernow/AutoDDU_CLI/blob/main/AutoDDU_CLI.py

Any help is greatly appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source