[3.8] gh-112275: Fix HEAD_LOCK deadlock in child process after fork (GH-112336) (GH-123688) (#123713)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork.
(cherry picked from commit
522799a05e3e820339718151ac055af6d864d463)
(cherry picked from commit
0152431f179e85f582a4c393aa3b99d3918a1109)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Co-authored-by: ChuBoning <102216855+ChuBoning@users.noreply.github.com>