Fix GUI window freeze on Windows during operations - #121
Conversation
On Windows, multiprocessing.Pool uses 'spawn' which re-imports __main__ in each child. When this happens from a non-main thread inside a --windowed PyInstaller binary, the spawn handshake blocks the Windows message pump, making the window unresponsive. This replaces the in-process cli_mkpfs_main() call with a subprocess.Popen child, keeping the GUI thread free. The subprocess handle is stored for a future stop/cancel button. Output is streamed line-by-line to the log pane. A --gui-subprocess router in the entry point allows the frozen binary to serve both GUI and CLI roles. Windows console-window flash is suppressed via CREATE_NO_WINDOW. Overwrite prompts are auto-confirmed via stdin. Closes #120.
Address code review feedback on PR #121: the bare pass in the BrokenPipeError/OSError handler was flagged. Added a comment explaining why it is safe to ignore (child crashed before reading stdin; the streaming loop will surface the error).
Code ReviewOverviewThe subprocess approach is sound — it avoids 🔴 Bug 1 — Progress bar spam:
|
🤔 Why?
On Windows, starting any operation (pack folder, pack file, verify) made the entire GUI window freeze — "Not responding" in the title bar until the command finished. The window couldn't be moved or interacted with.
The root cause:
multiprocessing.Poolusesspawnon Windows, which re-imports__main__in each child process. When this happens from a non-main thread inside a--windowedPyInstaller binary, the spawn handshake blocks the Windows message pump. macOS usesforkand was never affected.🔧 What changed
cli_mkpfs_main()call inBasePanel._run_mkpfswith asubprocess.Popenchild that streams output back to the log pane--gui-subprocessrouter inmkpfs/gui/__main__.pyso the frozen binary runs the CLI instead of the GUI when the marker is presentPopenhandle onself._procfor a future stop/cancel buttonCREATE_NO_WINDOW(essential for dev mode, harmless on frozen exe)"y\n"to stdin (replacing the oldbuiltins.inputpatch)🧪 How to test
💬 Notes