@@ -2130,22 +2130,23 @@ make_pre_finalization_calls(PyThreadState *tstate, int subinterpreters)
21302130 // XXX Why does _PyThreadState_DeleteList() rely on all interpreters
21312131 // being stopped?
21322132 _PyEval_StopTheWorldAll (interp -> runtime );
2133- _PyRWMutex_Lock (& interp -> finalization_locks .lock );
2133+ _PyRWMutex_Lock (& interp -> finalization_guards .lock );
21342134 int has_subinterpreters = subinterpreters
21352135 ? runtime_has_subinterpreters (interp -> runtime )
21362136 : 0 ;
2137- // TODO: The interpreter reference countdown probably isn't very efficient.
2137+ // TODO: The interpreter guard countdown isn't very efficient. We should
2138+ // wait on an event or something like that.
21382139 int should_continue = (interp_has_threads (interp )
21392140 || interp_has_atexit_callbacks (interp )
21402141 || interp_has_pending_calls (interp )
21412142 || has_subinterpreters
2142- || interp -> finalization_locks .countdown > 0 );
2143+ || interp -> finalization_guards .countdown > 0 );
21432144 if (!should_continue ) {
21442145 break ;
21452146 }
21462147 // Temporarily let other threads execute
21472148 _PyThreadState_Detach (tstate );
2148- _PyRWMutex_Unlock (& interp -> finalization_locks .lock );
2149+ _PyRWMutex_Unlock (& interp -> finalization_guards .lock );
21492150 _PyEval_StartTheWorldAll (interp -> runtime );
21502151 PyMutex_Unlock (& interp -> ceval .pending .mutex );
21512152 _PyThreadState_Attach (tstate );
@@ -2209,7 +2210,7 @@ _Py_Finalize(_PyRuntimeState *runtime)
22092210 for (PyThreadState * p = list ; p != NULL ; p = p -> next ) {
22102211 _PyThreadState_SetShuttingDown (p );
22112212 }
2212- _PyRWMutex_Unlock (& tstate -> interp -> finalization_locks .lock );
2213+ _PyRWMutex_Unlock (& tstate -> interp -> finalization_guards .lock );
22132214 _PyEval_StartTheWorldAll (runtime );
22142215 PyMutex_Unlock (& tstate -> interp -> ceval .pending .mutex );
22152216
@@ -2579,7 +2580,7 @@ Py_EndInterpreter(PyThreadState *tstate)
25792580 _PyThreadState_SetShuttingDown (p );
25802581 }
25812582
2582- _PyRWMutex_Unlock (& interp -> finalization_locks .lock );
2583+ _PyRWMutex_Unlock (& interp -> finalization_guards .lock );
25832584 _PyEval_StartTheWorldAll (interp -> runtime );
25842585 PyMutex_Unlock (& interp -> ceval .pending .mutex );
25852586 _PyThreadState_DeleteList (list , /*is_after_fork=*/ 0 );
0 commit comments