diff options
author | Victor Stinner <vstinner@python.org> | 2020-05-06 16:25:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 16:25:06 (GMT) |
commit | d8135e913ab7c694db247c86d0a84c450c32d86e (patch) | |
tree | ea0c95513b28a2fd0102f59a3e9505cc0dd2e93e /Modules/gcmodule.c | |
parent | 89fc4a34cf7a01df9dd269d32d3706c68a72d130 (diff) | |
download | cpython-d8135e913ab7c694db247c86d0a84c450c32d86e.zip cpython-d8135e913ab7c694db247c86d0a84c450c32d86e.tar.gz cpython-d8135e913ab7c694db247c86d0a84c450c32d86e.tar.bz2 |
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.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 56dcb10..a44752b 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -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); |