Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-112087: Test fix for test_sched leak #116237

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/internal/pycore_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ extern PyObject *_PyGC_GetReferrers(PyInterpreterState *interp, PyObject *objs);
extern void _PyGC_ClearAllFreeLists(PyInterpreterState *interp);
extern void _Py_ScheduleGC(PyThreadState *tstate);
extern void _Py_RunGC(PyThreadState *tstate);
#ifdef Py_GIL_DISABLED
extern void _PyGC_Clear_DelayedObjects(PyInterpreterState *interp);
#endif

#ifdef __cplusplus
}
Expand Down
13 changes: 13 additions & 0 deletions Python/gc_free_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
}
}

_PyGC_Clear_DelayedObjects(interp);
/* Update stats */
struct gc_generation_stats *stats = &gcstate->generation_stats[generation];
stats->collections++;
Expand Down Expand Up @@ -1758,4 +1759,16 @@ _PyGC_ClearAllFreeLists(PyInterpreterState *interp)
HEAD_UNLOCK(&_PyRuntime);
}

void
_PyGC_Clear_DelayedObjects(PyInterpreterState *interp)
{
HEAD_LOCK(&_PyRuntime);
PyThreadState *tstate = interp->threads.head;
while (tstate != NULL) {
_PyMem_ProcessDelayed(tstate);
tstate = (PyThreadState *)tstate->next;
}
HEAD_UNLOCK(&_PyRuntime);
}

#endif // Py_GIL_DISABLED
Loading