From ce6bd79bb93561136cef5e535817f22bfa5b9206 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Wed, 16 Oct 2024 06:56:23 +0000 Subject: [PATCH] minor fixes --- Modules/_testcapimodule.c | 1 + Python/ceval_gil.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index eb01566e3466715..7fe3e381c623df8 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -861,6 +861,7 @@ pending_threadfunc(PyObject *self, PyObject *arg, PyObject *kwargs) unsigned int num_added = 0; for (; num_added < num; num_added++) { if (Py_AddPendingCall(&_pending_callback, callable) < 0) { + // out of memory and freelist is empty break; } } diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index b148e9e05557a7a..36aba5fcf1762aa 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -1085,6 +1085,8 @@ Py_MakePendingCalls(void) void _PyEval_InitState(PyInterpreterState *interp) { + // Fill the pending freelist so that signal handlers can safely + // add pending calls without needing to allocate memory. struct _pending_calls *pending = &interp->ceval.pending; PyMutex_Lock(&pending->mutex); fill_pending_freelist(pending);