FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-126631: fix pre-loading of __main__ by duaneg · Pull Request #135295 · python/cpython · GitHub

Repository navigation

gh-126631: fix pre-loading of __main__ - #135295

Merged
gpshead merged 5 commits into
python:mainfrom
duaneg:gh-126631
Sep 7, 2025
Merged

gpshead merged 5 commits into
python:mainfrom
duaneg:gh-126631

Conversation

duaneg commented Jun 9, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

The main_path parameter was renamed init_main_from_name, update the forkserver code accordingly.

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.
duaneg marked this pull request as ready for review June 10, 2025 09:45
duaneg requested a review from gpshead as a code owner June 10, 2025 09:45

duaneg commented Jun 10, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

If/when #135335 is fixed we can remove the explicit flush from the test script. Likewise, if/when this is fixed the regression test in the PR for that issue can be simplified to just use a script (preloading __main__) instead of having to create and import a module.

Copy link
Copy Markdown

@gpshead could we proceed with this PR in favor of my #138048 (which is essentially identical, but lacks test coverage)? This would fix the performance issue reported in #137996.

duaneg commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

@gpshead could we proceed with this PR in favor of my #138048 (which is essentially identical, but lacks test coverage)?

FTR, I'd be perfectly fine with you copying the regression test from this into your PR, too. Whatever is easiest!

gpshead self-assigned this Sep 7, 2025
gpshead added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error labels Sep 7, 2025
gpshead enabled auto-merge (squash) September 7, 2025 07:27
gpshead merged commit 0912b3a into python:main Sep 7, 2025
51 checks passed

Copy link
Copy Markdown

Thanks @duaneg for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 7, 2025
…onGH-135295)

pythongh-126631: pythongh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------
(cherry picked from commit 0912b3a)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>

Copy link
Copy Markdown

Sorry, @duaneg and @gpshead, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 0912b3a6dbd226bea79eb8d70d5a06230804d4cb 3.13

bedevere-app Bot commented Sep 7, 2025

Copy link
Copy Markdown

GH-138607 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 7, 2025
gpshead added a commit to gpshead/cpython that referenced this pull request Sep 7, 2025
pythonGH-135295)

pythongh-126631: pythongh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------
(cherry picked from commit 0912b3a)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>

bedevere-app Bot commented Sep 7, 2025

Copy link
Copy Markdown

GH-138609 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 7, 2025
gpshead added a commit that referenced this pull request Sep 8, 2025
#138609)

gh-126631: gh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------
(cherry picked from commit 0912b3a)

Co-authored-by: Duane Griffin <duaneg@dghda.com>

Copy link
Copy Markdown

Thanks a lot, @duaneg and @gpshead!

lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
…onGH-135295)

pythongh-126631: pythongh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
gpshead added a commit that referenced this pull request Oct 8, 2025
#138607)

gh-126631: gh-137996: fix pre-loading of `__main__` (GH-135295)

gh-126631: gh-137996: fix pre-loading of `__main__`

The `main_path` parameter was renamed `init_main_from_name`, update the
forkserver code accordingly.  This was leading to slower startup times when people
were trying to preload the main module.

---------
(cherry picked from commit 0912b3a)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gpshead added a commit that referenced this pull request Jan 18, 2026
…er_preload` (GH-141859)

Add a keyword-only `on_error` parameter to `multiprocessing.set_forkserver_preload()`. This allows the user to have exceptions during optional `forkserver` start method module preloading cause the forkserver subprocess to warn (generally to stderr) or exit with an error (preventing use of the forkserver) instead of being silently ignored.

This _also_ fixes an oversight, errors when preloading a `__main__` module are now treated the similarly. Those would always raise unlike other modules in preload, but that had gone unnoticed as up until bug fix PR GH-135295 in 3.14.1 and 3.13.8, the `__main__` module was never actually preloaded.

Based on original work by Nick Neumann @aggieNick02 in GH-99515.
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
…rkserver_preload` (pythonGH-141859)

Add a keyword-only `on_error` parameter to `multiprocessing.set_forkserver_preload()`. This allows the user to have exceptions during optional `forkserver` start method module preloading cause the forkserver subprocess to warn (generally to stderr) or exit with an error (preventing use of the forkserver) instead of being silently ignored.

This _also_ fixes an oversight, errors when preloading a `__main__` module are now treated the similarly. Those would always raise unlike other modules in preload, but that had gone unnoticed as up until bug fix PR pythonGH-135295 in 3.14.1 and 3.13.8, the `__main__` module was never actually preloaded.

Based on original work by Nick Neumann @aggieNick02 in pythonGH-99515.
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

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL