From 7fab75fcbb4ce36d09b45383de20640124aba3ff Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Mon, 10 Feb 2025 07:55:30 +0000 Subject: [PATCH] simplify --- Modules/_asynciomodule.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 656c03a98d73b2..4070076d756fcf 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -4102,6 +4102,12 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop) Py_DECREF(loop); return NULL; } + if (PyList_Extend(tasks, state->non_asyncio_tasks) < 0) { + Py_DECREF(tasks); + Py_DECREF(loop); + return NULL; + } + PyInterpreterState *interp = PyInterpreterState_Get(); // Stop the world and traverse the per-thread linked list // of asyncio tasks for every thread, as well as the @@ -4127,24 +4133,7 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop) Py_DECREF(loop); return NULL; } - PyObject *scheduled_iter = PyObject_GetIter(state->non_asyncio_tasks); - if (scheduled_iter == NULL) { - Py_DECREF(tasks); - Py_DECREF(loop); - return NULL; - } - PyObject *item; - while ((item = PyIter_Next(scheduled_iter)) != NULL) { - if (PyList_Append(tasks, item) < 0) { - Py_DECREF(tasks); - Py_DECREF(loop); - Py_DECREF(item); - Py_DECREF(scheduled_iter); - return NULL; - } - Py_DECREF(item); - } - Py_DECREF(scheduled_iter); + // All the tasks are now in the list, now filter the tasks which are done PyObject *res = PySet_New(NULL); if (res == NULL) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy