@@ -1131,16 +1131,18 @@ Py_FinalizeEx(void)
1131
1131
return status ;
1132
1132
}
1133
1133
1134
+ /* Get current thread state and interpreter pointer */
1135
+ PyThreadState * tstate = _PyThreadState_GET ();
1136
+ PyInterpreterState * interp = tstate -> interp ;
1137
+
1134
1138
// Wrap up existing "threading"-module-created, non-daemon threads.
1135
1139
wait_for_thread_shutdown ();
1140
+ interp -> finalizing = 1 ;
1141
+
1136
1142
1137
1143
// Make any remaining pending calls.
1138
1144
_Py_FinishPendingCalls ();
1139
1145
1140
- /* Get current thread state and interpreter pointer */
1141
- PyThreadState * tstate = _PyThreadState_GET ();
1142
- PyInterpreterState * interp = tstate -> interp ;
1143
-
1144
1146
/* The interpreter is still entirely intact at this point, and the
1145
1147
* exit funcs may be relying on that. In particular, if some thread
1146
1148
* or exit func is still waiting to do an import, the import machinery
@@ -1546,10 +1548,10 @@ Py_EndInterpreter(PyThreadState *tstate)
1546
1548
Py_FatalError ("Py_EndInterpreter: thread is not current" );
1547
1549
if (tstate -> frame != NULL )
1548
1550
Py_FatalError ("Py_EndInterpreter: thread still has a frame" );
1549
- interp -> finalizing = 1 ;
1550
1551
1551
1552
// Wrap up existing "threading"-module-created, non-daemon threads.
1552
1553
wait_for_thread_shutdown ();
1554
+ interp -> finalizing = 1 ;
1553
1555
1554
1556
call_py_exitfuncs (interp );
1555
1557
0 commit comments