Fix native mode crash on Linux Python 3.14 (forkserver default) - #156
Open
evnchn wants to merge 1 commit into
Open
Fix native mode crash on Linux Python 3.14 (forkserver default)#156evnchn wants to merge 1 commit into
evnchn wants to merge 1 commit into
Conversation
Fixes zauberzeug#6062. zauberzeug#6045 migrated the native-mode IPC primitives (Queue, Pipe, Event) to SPAWN_CONTEXT but left the Process on the default context. Python 3.14 changed the Linux default start method from 'fork' to 'forkserver', which re-imports the user's main module to bootstrap workers but does NOT use the '--multiprocessing-fork' argv trampoline that lets mp.freeze_support() short-circuit, so the doc example crashes with: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. Switching the Process to SPAWN_CONTEXT keeps every native-mode IPC primitive on the same context and works on all supported Pythons: spawn's trampoline runs the target and exits the child before reaching ui.run() on re-import, so app.native.window_args / start_args / settings set in the user script still propagate correctly.
4 tasks
evnchn
force-pushed
the
fix/native-mp-forkserver-py314
branch
from
May 20, 2026 13:34
db2a91f to
b6ff21c
Compare
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.
Spike for upstream issue zauberzeug/nicegui#6062. Completes the spawn-context migration started in #6045, which moved Queue/Pipe/Event to
SPAWN_CONTEXTbut leftmp.Processon the default context.Python 3.14 changed the Linux multiprocessing default from
forktoforkserver. Forkserver re-imports the user's main module to bootstrap workers but does not use the--multiprocessing-forkargv trampoline, somp.freeze_support()cannot short-circuit and_check_not_importing_main()raises:Fix: one-line change to
native.SPAWN_CONTEXT.Process(...). Spawn's trampoline runs the target and exits before reachingui.run()in the child, soapp.native.window_args/start_args/settingsset in the user script still propagate correctly (verified empirically on Linux 3.14.5 and macOS 3.14.4).