mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-16500: Use register_at_fork() in the threading module (#1843)
* bpo-16500: Use register_at_fork() in the threading module * Update comment at top of _after_fork()
This commit is contained in:
@@ -240,8 +240,6 @@ PyEval_ReleaseThread(PyThreadState *tstate)
|
||||
void
|
||||
PyEval_ReInitThreads(void)
|
||||
{
|
||||
_Py_IDENTIFIER(_after_fork);
|
||||
PyObject *threading, *result;
|
||||
PyThreadState *current_tstate = PyThreadState_GET();
|
||||
|
||||
if (!gil_created())
|
||||
@@ -251,22 +249,6 @@ PyEval_ReInitThreads(void)
|
||||
take_gil(current_tstate);
|
||||
main_thread = PyThread_get_thread_ident();
|
||||
|
||||
/* Update the threading module with the new state.
|
||||
*/
|
||||
threading = PyMapping_GetItemString(current_tstate->interp->modules,
|
||||
"threading");
|
||||
if (threading == NULL) {
|
||||
/* threading not imported */
|
||||
PyErr_Clear();
|
||||
return;
|
||||
}
|
||||
result = _PyObject_CallMethodId(threading, &PyId__after_fork, NULL);
|
||||
if (result == NULL)
|
||||
PyErr_WriteUnraisable(threading);
|
||||
else
|
||||
Py_DECREF(result);
|
||||
Py_DECREF(threading);
|
||||
|
||||
/* Destroy all threads except the current one */
|
||||
_PyThreadState_DeleteExcept(current_tstate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user