8000 gh-105716: Support Background Threads in Subinterpreters Consistently by ericsnowcurrently · Pull Request #109921 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-105716: Support Background Threads in Subinterpreters Consistently #109921

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
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4e88c2b
Always wait for threads in subinterpreters.
ericsnowcurrently Sep 25, 2023
d08ac68
Add PyInterpreterState_*RunningMain().
ericsnowcurrently Sep 26, 2023
3b07482
Drop interpreter_exists().
ericsnowcurrently Sep 26, 2023
70c4753
Drop PyThreadState_IsRunning().
ericsnowcurrently Sep 26, 2023
678cb3b
Add a TODO.
ericsnowcurrently Sep 26, 2023
5be5a07
For now use the earliest thread state.
ericsnowcurrently Sep 26, 2023
81a1e0b
Add tests.
ericsnowcurrently Sep 26, 2023
c3f497b
Mark the main interpreter as running __main__.
ericsnowcurrently Sep 26, 2023
effa5b4
Call PyInterpreterState_SetNotRunningMain() in the right place.
ericsnowcurrently Sep 26, 2023
41c54b0
Check PyInterpreterState_IsRunningMain() preemptively, for now.
ericsnowcurrently Sep 26, 2023
5fbd940
Add docs.
ericsnowcurrently Sep 26, 2023
8b54c2e
Add a NEWS entry.
ericsnowcurrently Sep 26, 2023
5d1df61
Fix a typo.
ericsnowcurrently Sep 27, 2023
1034a67
Update the docs.
ericsnowcurrently Sep 27, 2023
d57729e
Update the docs.
ericsnowcurrently Sep 27, 2023
4219e2c
Update the docs.
ericsnowcurrently Sep 27, 2023
bfdace2
Drop a dead line.
ericsnowcurrently Sep 27, 2023
ef8af92
Drop an unused parameter.
ericsnowcurrently Sep 27, 2023
566cd08
Drop an unnecessary variable.
ericsnowcurrently Sep 27, 2023
d14b87a
Update TODO comments.
ericsnowcurrently Sep 27, 2023
1f2a321
Merge branch 'main' into subinterpreters-allow-background-threads
ericsnowcurrently Sep 27, 2023
55d7090
Merge branch 'main& 8000 #39; into subinterpreters-allow-background-threads
ericsnowcurrently Sep 29, 2023
399859f
Do not expose the "Running" C-API (for now).
ericsnowcurrently Oct 2, 2023
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
Drop interpreter_exists().
  • Loading branch information
ericsnowcurrently committed Sep 26, 2023
commit 3b07482e17f89078775286058e5c39b22abecb51
24 changes: 0 additions & 24 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,17 +1121,9 @@ PyInterpreterState_SetNotRunningMain(PyInterpreterState *interp)
interp->threads.main = NULL;
}

static int interpreter_exists(PyInterpreterState *);

int
PyInterpreterState_IsRunningMain(PyInterpreterState *interp)
{
HEAD_LOCK(interp->runtime);
int exists = interpreter_exists(interp);
HEAD_UNLOCK(interp->runtime);
if (!exists) {
return 0;
}
if (interp->threads.main == NULL) {
return 0;
}
Expand Down Expand Up @@ -1248,22 +1240,6 @@ PyInterpreterState_GetDict(PyInterpreterState *interp)
// look up an interpreter state
//-----------------------------

/* This must be called with the "head" lock held. */
static int
interpreter_exists(PyInterpreterState *interp)
{
PyInterpreterState *actual = interp->runtime->interpreters.head;
while (actual != NULL) {
if (actual == interp) {
return 1;
}
actual = actual->next;
}
// It's a dangling pointer.
return 0;
}


/* Return the interpreter associated with the current OS thread.

The GIL must be held.
Expand Down
0