Skip to content

Commit e202848

Browse files
committed
Fix ordering of finalization calls.
1 parent e57bfde commit e202848

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Python/pylifecycle.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,9 +2128,6 @@ _Py_Finalize(_PyRuntimeState *runtime)
21282128
// Block some operations.
21292129
tstate->interp->finalizing = 1;
21302130

2131-
// This call stops the world and takes the pending calls lock.
2132-
make_pre_finalization_calls(tstate);
2133-
21342131
/* Clean up any lingering subinterpreters.
21352132
21362133
Two preconditions need to be met here:
@@ -2139,8 +2136,12 @@ _Py_Finalize(_PyRuntimeState *runtime)
21392136
called, or else threads might get prematurely blocked.
21402137
- The world must not be stopped, as finalizers can run.
21412138
*/
2139+
// TODO: Prevent new subinterpreters after this point
21422140
finalize_subinterpreters();
21432141

2142+
// This call stops the world and takes the pending calls lock.
2143+
make_pre_finalization_calls(tstate);
2144+
21442145
assert(_PyThreadState_GET() == tstate);
21452146

21462147
/* Copy the core config, PyInterpreterState_Delete() free

0 commit comments

Comments
 (0)