File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1253,17 +1253,20 @@ finalize_interp_clear(PyThreadState *tstate)
1253
1253
{
1254
1254
int is_main_interp = _Py_IsMainInterpreter (tstate );
1255
1255
1256
- /* bpo-36854: Explicitly clear the codec registry
1257
- and trigger a GC collection */
1256
+ /* bpo-36854: Explicitly clear the codec registry */
1258
1257
PyInterpreterState * interp = tstate -> interp ;
1259
1258
Py_CLEAR (interp -> codec_search_path );
1260
1259
Py_CLEAR (interp -> codec_search_cache );
1261
1260
Py_CLEAR (interp -> codec_error_registry );
1262
- _PyGC_CollectNoFail ();
1263
1261
1264
1262
/* Clear interpreter state and all thread states */
1265
1263
PyInterpreterState_Clear (tstate -> interp );
1266
1264
1265
+ /* Trigger a GC collection on subinterpreters*/
1266
+ if (!is_main_interp ) {
1267
+ _PyGC_CollectNoFail ();
1268
+ }
1269
+
1267
1270
finalize_interp_types (tstate , is_main_interp );
1268
1271
1269
1272
if (is_main_interp ) {
You can’t perform that action at this time.
0 commit comments