Fix Windows crash on GUI success logs - #123
Open
RenanGBarreto wants to merge 4 commits into
Open
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 Coverage OverviewLanguages: Python Python / code-coverage/pytestThe overall line coverage in commit 9a6520e in the Show a line coverage summary of the most impacted files.
Updated |
| try: | ||
| proc.stdin.write("y\n") | ||
| proc.stdin.close() | ||
| except (BrokenPipeError, OSError): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Windows crash on GUI success logs
🤔 Why?
On Windows, the GUI runs the CLI as a subprocess and pipes its stdout. Those pipes often use the system ANSI code page (e.g., cp1252). When a success message includes a non‑ASCII glyph (like an emoji),
print()can raiseUnicodeEncodeError, causing the GUI to report a failure even though the image was written successfully. See #122.🔧 What changed
UnicodeEncodeErrorinlogging.log()and retry with an ASCII‑only fallback (sanitized text and ASCII icon when provided).stdout/stderrto UTF‑8 witherrors="replace"when available (guarded withcontextlib.suppress).🧪 How to test
pytest tests/mkpfs/test_logging.py.Closes #122.