Windows Console Popup in Python Subprocess
Another esoteric python issue on windows for which there is little documentation. When running a subprocess a console window will popup. This can be especially bad UX if you are running multiple fast subprocesses. The user will see a series of flashing terminal windows. For me, this only happened when the app was bundled into a exe by PyInstaller (see my other post on the nightmare that is), and not when running as a module with python -m modulename
(i.e.: runpy).
I found the solution in a series of stackoverflow posts:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.run(args, creationflags=subprocess.CREATE_NO_WINDOW, startupinfo=startupinfo)