summaryrefslogtreecommitdiffstats
path: root/Python/ceval_gil.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-03-21 18:21:02 (GMT)
committerGitHub <noreply@github.com>2024-03-21 18:21:02 (GMT)
commit1f72fb5447ef3f8892b4a7a6213522579c618e8e (patch)
tree43997f5d50ff319adc557320b277a68ddf38099d /Python/ceval_gil.c
parent50369e6c34d05222e5a0ec9443a9f7b230e83112 (diff)
downloadcpython-1f72fb5447ef3f8892b4a7a6213522579c618e8e.zip
cpython-1f72fb5447ef3f8892b4a7a6213522579c618e8e.tar.gz
cpython-1f72fb5447ef3f8892b4a7a6213522579c618e8e.tar.bz2
gh-116522: Refactor `_PyThreadState_DeleteExcept` (#117131)
Split `_PyThreadState_DeleteExcept` into two functions: - `_PyThreadState_RemoveExcept` removes all thread states other than one passed as an argument. It returns the removed thread states as a linked list. - `_PyThreadState_DeleteList` deletes those dead thread states. It may call destructors, so we want to "start the world" before calling `_PyThreadState_DeleteList` to avoid potential deadlocks.
Diffstat (limited to 'Python/ceval_gil.c')
-rw-r--r--Python/ceval_gil.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c
index 78c13d6..d88ac65 100644
--- a/Python/ceval_gil.c
+++ b/Python/ceval_gil.c
@@ -579,9 +579,8 @@ PyEval_ReleaseThread(PyThreadState *tstate)
}
#ifdef HAVE_FORK
-/* This function is called from PyOS_AfterFork_Child to destroy all threads
- which are not running in the child process, and clear internal locks
- which might be held by those threads. */
+/* This function is called from PyOS_AfterFork_Child to re-initialize the
+ GIL and pending calls lock. */
PyStatus
_PyEval_ReInitThreads(PyThreadState *tstate)
{
@@ -598,8 +597,6 @@ _PyEval_ReInitThreads(PyThreadState *tstate)
struct _pending_calls *pending = &tstate->interp->ceval.pending;
_PyMutex_at_fork_reinit(&pending->mutex);
- /* Destroy all threads except the current one */
- _PyThreadState_DeleteExcept(tstate);
return _PyStatus_OK();
}
#endif