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

Appearance settings

gh-128639: Don't assume one thread in subinterpreter finalization #128640

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
  • Loading branch information
ZeroIntensity and ericsnowcurrently authored May 19, 2025
commit 1555731dc2ea6acb895f17f4e20d30fb9041dade
6 changes: 1 addition & 5 deletions 6 Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,6 @@ resolve_final_tstate(_PyRuntimeState *runtime)

/* We might want to warn if main_tstate->current_frame != NULL. */

assert(main_tstate->interp == main_interp);
return main_tstate;
}

Expand All @@ -2007,8 +2006,6 @@ _Py_Finalize(_PyRuntimeState *runtime)

/* Get final thread state pointer. */
PyThreadState *tstate = resolve_final_tstate(runtime);
// We must be in the main interpreter
assert(tstate->interp == &runtime->_main_interpreter);

// Block some operations.
tstate->interp->finalizing = 1;
Expand Down Expand Up @@ -2513,8 +2510,7 @@ finalize_subinterpreters(void)
while (interp != NULL) {
/* Make a tstate for finalization. */
PyThreadState *tstate = _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_FINI);
ericsnowcurrently marked this conversation as resolved.
Show resolved Hide resolved
if (tstate == NULL)
{
if (tstate == NULL) {
// XXX Some graceful way to always get a thread state?
Py_FatalError("thread state allocation failed");
ZeroIntensity marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.