Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make any remaining pending calls before shutdown.
  • Loading branch information
ericsnowcurrently committed Sep 15, 2018
commit 1ceba050231c1eac0f8ca7bc024829e6a2ea3da8
15 changes: 15 additions & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,21 @@ Py_EndInterpreter(PyThreadState *tstate)
Py_FatalError("Py_EndInterpreter: thread still has a frame");

wait_for_thread_shutdown();
// XXX Forcibly mark current thread as active?
assert(interp->ceval.active);
assert(interp->ceval.active_thread == PyThread_get_thread_ident());

if (_Py_atomic_load_relaxed(
&(interp->ceval.pending.calls_to_do)))
{
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);

Expand Down
2 changes: 0 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ void
PyInterpreterState_Clear(PyInterpreterState *interp)
{
PyThreadState *p;
// XXX Also ensure that all pending calls have been made. Disallow
// registration of more pending calls.
HEAD_LOCK();
for (p = interp->tstate_head; p != NULL; p = p->next)
PyThreadState_Clear(p);
Expand Down