mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
bpo-40232: Update PyOS_AfterFork_Child() to use _PyThread_at_fork_reinit() (GH-19450)
This commit is contained in:
parent
e5014be049
commit
62f75fe3dd
6 changed files with 21 additions and 13 deletions
|
@ -397,6 +397,7 @@ PyEval_ReleaseThread(PyThreadState *tstate)
|
|||
drop_gil(&runtime->ceval, 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.
|
||||
|
@ -416,14 +417,14 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime)
|
|||
take_gil(tstate);
|
||||
|
||||
struct _pending_calls *pending = &tstate->interp->ceval.pending;
|
||||
pending->lock = PyThread_allocate_lock();
|
||||
if (pending->lock == NULL) {
|
||||
if (_PyThread_at_fork_reinit(&pending->lock) < 0) {
|
||||
Py_FatalError("Can't initialize threads for pending calls");
|
||||
}
|
||||
|
||||
/* Destroy all threads except the current one */
|
||||
_PyThreadState_DeleteExcept(runtime, tstate);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is used to signal that async exceptions are waiting to be
|
||||
raised. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue