You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyThreadState Sometimes Used for Different Threads for Subinterpreters #109860
In a few places, we treat PyInterpreterState.threads.head (AKA PyInterpreterState_ThreadHead()) for subinterpreters as an unused thread state that we can use in a one-off manner:
The problem is that each thread state should correspond to a single OS thread, and for each OS thread there should be at most one thread state per interpreter. Using PyInterpreterState.threads.head like that violates those assumptions, which can cause problems. 1
Also, some code assumes PyInterpreterState.threads.head is the current thread state, when it might not be:
interpreter_clear() (Python/pystate.c)
...
We should fix this by always using the thread state that corresponds to the current thread (and create one if missing). For efficiency, we can use a thread-local (via PyThread_tss_*) to store each interpreter's thread state for that thread.
Activity
gh-109860: Use a New Thread State When Switching Interpreters, When N…
[3.12] pythongh-109860: Use a New Thread State When Switching Interpr…
[3.12] pythongh-109860: Use a New Thread State When Switching Interpr…
pythongh-109860: Use a New Thread State When Switching Interpreters, …