From de192325e1ee9abe67670d6fa68d9f7f6dd16178 Mon Sep 17 00:00:00 2001 From: Phil Underwood Date: Sat, 8 Jul 2023 17:17:25 +0100 Subject: [PATCH] Release references to `cur_task` and `_exc_context` when creating a new event loop This helps with memory management --- asyncio/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/asyncio/core.py b/asyncio/core.py index 149b46f..53ef98a 100644 --- a/asyncio/core.py +++ b/asyncio/core.py @@ -394,11 +394,14 @@ def new_event_loop(): the loop's state, it does not create a new one """ - global _task_queue, _io_queue + global _task_queue, _io_queue, _exc_context, cur_task # TaskQueue of Task instances _task_queue = TaskQueue() # Task queue and poller for stream IO _io_queue = IOQueue() + cur_task = None + _exc_context['exception'] = None + _exc_context['future'] = None return Loop