]> 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 1cc3c947087e368740a91c8581b04081ecd772ab..bafb88c160b00465c24ad286d0728c38ec5dc137 100644 (file)
@@ -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");
             }