aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Python/gc_free_threading.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 59e76012f8f..2b13d1f005d 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -1603,6 +1603,10 @@ _PyObject_GC_Link(PyObject *op)
void
_Py_RunGC(PyThreadState *tstate)
{
+ GCState *gcstate = get_gc_state();
+ if (!gcstate->enabled) {
+ return;
+ }
gc_collect_main(tstate, 0, _Py_GC_REASON_HEAP);
}