From 3f1669e8edb49d4af74f7b7686215973b4766229 Mon Sep 17 00:00:00 2001 From: btharper Date: Sat, 5 Oct 2019 13:35:26 -0400 Subject: [PATCH 1/3] Fix memory leak during setup.py build_ext --- Modules/_asynciomodule.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index b67afd41768fe5..a01acef96b2a71 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -3248,7 +3248,9 @@ module_init(void) goto fail; } - current_tasks = PyDict_New(); + if (current_tasks == NULL) { + current_tasks = PyDict_New(); + } if (current_tasks == NULL) { goto fail; } @@ -3259,7 +3261,9 @@ module_init(void) } - context_kwname = Py_BuildValue("(s)", "context"); + if (context_kwname == NULL) { + context_kwname = Py_BuildValue("(s)", "context"); + } if (context_kwname == NULL) { goto fail; } From 4a342f94c27f1f84dfa0932b89bcd45f2c7b7a1a Mon Sep 17 00:00:00 2001 From: btharper Date: Sat, 5 Oct 2019 22:19:29 -0400 Subject: [PATCH 2/3] Ensure asyncio initialization only happens once --- Modules/_asynciomodule.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index a01acef96b2a71..8d09742d96c487 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -33,6 +33,7 @@ static PyObject *asyncio_task_repr_info_func; static PyObject *asyncio_InvalidStateError; static PyObject *asyncio_CancelledError; static PyObject *context_kwname; +static int module_initialized; static PyObject *cached_running_holder; static volatile uint64_t cached_running_holder_tsid; @@ -3247,10 +3248,13 @@ module_init(void) if (asyncio_mod == NULL) { goto fail; } - - if (current_tasks == NULL) { - current_tasks = PyDict_New(); + if (module_initialized != 0) { + return 0; + } else { + module_initialized = 1; } + + current_tasks = PyDict_New(); if (current_tasks == NULL) { goto fail; } @@ -3261,9 +3265,7 @@ module_init(void) } - if (context_kwname == NULL) { - context_kwname = Py_BuildValue("(s)", "context"); - } + context_kwname = Py_BuildValue("(s)", "context"); if (context_kwname == NULL) { goto fail; } From 604b6150966a3e6070e13b4ec948edad1af72525 Mon Sep 17 00:00:00 2001 From: Ben Harper Date: Mon, 7 Oct 2019 09:39:32 -0400 Subject: [PATCH 3/3] Fix brackets on else clause Co-Authored-By: Yury Selivanov --- Modules/_asynciomodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 8d09742d96c487..89b2fdea0f6321 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -3250,7 +3250,8 @@ module_init(void) } if (module_initialized != 0) { return 0; - } else { + } + else { module_initialized = 1; } 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