Skip to content

Commit 321def8

Browse files
btharper1st1
authored andcommitted
bpo-36356: Fix memory leak in _asynciomodule.c (GH-16598)
1 parent 303475e commit 321def8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Modules/_asynciomodule.c

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static PyObject *asyncio_task_repr_info_func;
3333
static PyObject *asyncio_InvalidStateError;
3434
static PyObject *asyncio_CancelledError;
3535
static PyObject *context_kwname;
36+
static int module_initialized;
3637

3738
static PyObject *cached_running_holder;
3839
static volatile uint64_t cached_running_holder_tsid;
@@ -3247,6 +3248,12 @@ module_init(void)
32473248
if (asyncio_mod == NULL) {
32483249
goto fail;
32493250
}
3251+
if (module_initialized != 0) {
3252+
return 0;
3253+
}
3254+
else {
3255+
module_initialized = 1;
3256+
}
32503257

32513258
current_tasks = PyDict_New();
32523259
if (current_tasks == NULL) {

0 commit comments

Comments
 (0)