mirror of
https://github.com/python/cpython.git
synced 2025-10-21 06:02:21 +00:00
bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (GH-11617)
This involves moving the global "pending calls" state to PyInterpreterState. https://bugs.python.org/issue33608
This commit is contained in:
parent
463572c8be
commit
ef4ac967e2
10 changed files with 201 additions and 121 deletions
|
@ -1459,8 +1459,32 @@ Py_EndInterpreter(PyThreadState *tstate)
|
|||
if (tstate->frame != NULL)
|
||||
Py_FatalError("Py_EndInterpreter: thread still has a frame");
|
||||
|
||||
// Mark as finalizing.
|
||||
if (interp->ceval.pending.lock != NULL) {
|
||||
PyThread_acquire_lock(interp->ceval.pending.lock, 1);
|
||||
}
|
||||
interp->finalizing = 1;
|
||||
if (interp->ceval.pending.lock != NULL) {
|
||||
PyThread_release_lock(interp->ceval.pending.lock);
|
||||
}
|
||||
|
||||
// Wrap up existing threads.
|
||||
wait_for_thread_shutdown();
|
||||
|
||||
// Make any pending calls.
|
||||
if (_Py_atomic_load_relaxed(
|
||||
&(interp->ceval.pending.calls_to_do)))
|
||||
{
|
||||
// XXX Ensure that the interpreter is running in the current thread?
|
||||
if (_Py_MakePendingCalls(interp) < 0) {
|
||||
PyObject *exc, *val, *tb;
|
||||
PyErr_Fetch(&exc, &val, &tb);
|
||||
PyErr_BadInternalCall();
|
||||
_PyErr_ChainExceptions(exc, val, tb);
|
||||
PyErr_Print();
|
||||
}
|
||||
}
|
||||
|
||||
call_py_exitfuncs(interp);
|
||||
|
||||
if (tstate != interp->tstate_head || tstate->next != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue