Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-117953: Always Run Extension Init Func in Main Interpreter First#118157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrentlyericsnowcurrently commentedApr 22, 2024
edited
Loading

This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise). This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.

This supercedesgh-117487.

@ericsnowcurrently
Copy link
MemberAuthor

FYI, there's a refleak somewhere in here that I'm tracking down.

Copy link
Member

@zoobazooba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nothing jumps out at me looking like a refleak, unfortunately. Possible the first import is leaking something in the main interpreter and it's not being counted right in the subinterpreter? (Or vice versa)

* and then continue loading like normal. */

PyThreadState *main_tstate = NULL;
if (!_Py_IsMainInterpreter(tstate->interp)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this necessary ifswitch_to_main_interpreter is doing the same check?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It isn't necessary, but I wanted to be explicit about it. I'll see about cleaning that up.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fixed

@@ -1941,15 +2005,73 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0,
if (cached == NULL) {
goto error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we do this without switching back?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, I noticed that too and have already fixed it locally. 😄

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fixed

@ericsnowcurrentlyericsnowcurrentlyenabled auto-merge (squash)May 7, 2024 03:52
@ericsnowcurrentlyericsnowcurrently merged commitb2cd54a intopython:mainMay 7, 2024
36 checks passed
@ericsnowcurrentlyericsnowcurrently deleted the load-ext-in-main-interp-2 branchMay 7, 2024 04:22
SonicField pushed a commit to SonicField/cpython that referenced this pull requestMay 8, 2024
…irst (pythongh-118157)This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise).  This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.
ericsnowcurrently added a commit that referenced this pull requestJul 8, 2024
…121503)The change ingh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 8, 2024
pythongh-121503)The change inpythongh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.(cherry picked from commit15d48ae)Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
ericsnowcurrently added a commit that referenced this pull requestJul 8, 2024
…ds (gh-121517)The change ingh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.(cherry picked from commit15d48ae, AKAgh-121503)Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
pythongh-121503)The change inpythongh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
pythongh-121503)The change inpythongh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobazooba left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ericsnowcurrently@zooba

[8]ページ先頭

©2009-2025 Movatter.jp