8000 gh-109860: Use a New Thread State When Switching Interpreters, When Necessary by ericsnowcurrently · Pull Request #110245 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109860: Use a New Thread State When Switching Interpreters, When Necessary #110245

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
Show file tree
Hide file tree
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
Throw away the initial thread state.
  • Loading branch information
ericsnowcurrently committed Oct 2, 2023
commit 0b60d6dd568b89b18dcbd73c5b3dd8affe6b929d
4 changes: 4 additions & 0 deletions Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ interp_create(PyObject *self, PyObject *args, PyObject *kwds)
PyThreadState_Swap(save_tstate);
return NULL;
}

PyThreadState_Clear(tstate);
PyThreadState_Delete(tstate);

_PyInterpreterState_RequireIDRef(interp, 1);
return idobj;
}
Expand Down
2 changes: 0 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,6 @@ add_threadstate(PyInterpreterState *interp, PyThreadState *tstate,
PyThreadState *next)
{
assert(interp->threads.head != tstate);
assert((next != NULL && tstate->id != 1) ||
(next == NULL && tstate->id == 1));
if (next != NULL) {
assert(next->prev == NULL || next->prev == tstate);
next->prev = tstate;
Expand Down
0