Skip to content

Commit d8135e9

Browse files
authored
bpo-40533: Disable GC in subinterpreters (GH-19961)
When Python is built with experimental isolated interpreters, a garbage collection now does nothing in an isolated interpreter. Temporary workaround until subinterpreters stop sharing Python objects.
1 parent 89fc4a3 commit d8135e9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Modules/gcmodule.c

+8
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,14 @@ collect(PyThreadState *tstate, int generation,
11811181
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
11821182
GCState *gcstate = &tstate->interp->gc;
11831183

1184+
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
1185+
if (tstate->interp->config._isolated_interpreter) {
1186+
// bpo-40533: The garbage collector must not be run on parallel on
1187+
// Python objects shared by multiple interpreters.
1188+
return 0;
1189+
}
1190+
#endif
1191+
11841192
if (gcstate->debug & DEBUG_STATS) {
11851193
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
11861194
show_stats_each_generations(gcstate);

0 commit comments

Comments
 (0)