]> granicus.if.org Git - python/commitdiff
check if the thread is finalizing after retaking the GIL
authorBenjamin Peterson <benjamin@python.org>
Tue, 17 Jun 2014 05:59:07 +0000 (22:59 -0700)
committerBenjamin Peterson <benjamin@python.org>
Tue, 17 Jun 2014 05:59:07 +0000 (22:59 -0700)
Python/ceval.c

index b1f5e8eedb5560ed4f17fe3247c36a5821dafd51..e00860831f15f3d4425db0f42b167628480da45b 100644 (file)
@@ -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");