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: v2.7.8~37^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c78e6d96f48c8b779ddc988366fece38de1f698;p=python check if the thread is finalizing after retaking the GIL --- diff --git a/Python/ceval.c b/Python/ceval.c index b1f5e8eedb..e00860831f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1024,6 +1024,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* Other threads may run now */ PyThread_acquire_lock(interpreter_lock, 1); + + /* Check if we should make a quick exit. */ + if (_Py_Finalizing && _Py_Finalizing != tstate) { + PyThread_release_lock(interpreter_lock); + PyThread_exit_thread(); + } + if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate");