Skip to content

Commit

Permalink
bpo-40533: Disable GC in subinterpreters (GH-19961)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vstinner committed May 6, 2020
1 parent 89fc4a3 commit d8135e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,14 @@ collect(PyThreadState *tstate, int generation,
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
GCState *gcstate = &tstate->interp->gc;

#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (tstate->interp->config._isolated_interpreter) {
// bpo-40533: The garbage collector must not be run on parallel on
// Python objects shared by multiple interpreters.
return 0;
}
#endif

if (gcstate->debug & DEBUG_STATS) {
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
show_stats_each_generations(gcstate);
Expand Down

0 comments on commit d8135e9

Please sign in to comment.