Skip to content

Commit 1160c4d

Browse files
Make any remaining pending calls before shutdown.
1 parent 3fd1b0f commit 1160c4d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Python/pylifecycle.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,19 @@ Py_EndInterpreter(PyThreadState *tstate)
14611461

14621462
wait_for_thread_shutdown();
14631463

1464+
if (_Py_atomic_load_relaxed(
1465+
&(interp->ceval.pending.calls_to_do)))
1466+
{
1467+
// XXX Ensure that the interpreter is running in the current thread?
1468+
if (_Py_MakePendingCalls(interp) < 0) {
1469+
PyObject *exc, *val, *tb;
1470+
PyErr_Fetch(&exc, &val, &tb);
1471+
PyErr_BadInternalCall();
1472+
_PyErr_ChainExceptions(exc, val, tb);
1473+
PyErr_Print();
1474+
}
1475+
}
1476+
14641477
call_py_exitfuncs(interp);
14651478

14661479
if (tstate != interp->tstate_head || tstate->next != NULL)

Python/pystate.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ void
189189
PyInterpreterState_Clear(PyInterpreterState *interp)
190190
{
191191
PyThreadState *p;
192-
// XXX Also ensure that all pending calls have been made. Disallow
193-
// registration of more pending calls.
194192
HEAD_LOCK();
195193
for (p = interp->tstate_head; p != NULL; p = p->next)
196194
PyThreadState_Clear(p);

0 commit comments

Comments
 (0)