From: Benjamin Peterson Date: Tue, 17 Jun 2014 05:59:07 +0000 (-0700) Subject: check if the thread is finalizing after retaking the GIL X-Git-Tag: v3.4.2rc1~373 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=17548dda51ddd2fdc7641d8808b8f458f7f339fe;p=python check if the thread is finalizing after retaking the GIL --- diff --git a/Python/ceval.c b/Python/ceval.c index 1cc3c94708..bafb88c160 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1267,6 +1267,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* Other threads may run now */ take_gil(tstate); + + /* Check if we should make a quick exit. */ + if (_Py_Finalizing && _Py_Finalizing != tstate) { + drop_gil(tstate); + PyThread_exit_thread(); + } + if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate"); }