Skip to content

Commit 17548dd

Browse files
committed
check if the thread is finalizing after retaking the GIL
1 parent 6637565 commit 17548dd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Python/ceval.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
12671267
/* Other threads may run now */
12681268

12691269
take_gil(tstate);
1270+
1271+
/* Check if we should make a quick exit. */
1272+
if (_Py_Finalizing && _Py_Finalizing != tstate) {
1273+
drop_gil(tstate);
1274+
PyThread_exit_thread();
1275+
}
1276+
12701277
if (PyThreadState_Swap(tstate) != NULL)
12711278
Py_FatalError("ceval: orphan tstate");
12721279
}

0 commit comments

Comments
 (0)