From 5328e32d84aea4008d00895959ace5af2d2293a4 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 28 Jun 2023 18:27:03 +0300 Subject: [PATCH] gh-106176: Fix reference leak in importlib/_bootstrap.py --- Lib/importlib/_bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index c48fd506a0e4eb..bbd7298eda3f0f 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -85,6 +85,8 @@ def __enter__(self): def __exit__(self, *args, **kwargs): """Remove self.lock from this thread's _blocking_on list.""" self.blocked_on.remove(self.lock) + if not self.blocked_on: + del _blocking_on[self.thread_id] class _DeadlockError(RuntimeError):