summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/_bootstrap.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r--Lib/importlib/_bootstrap.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index bebe7e1..1ef7b6a 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -85,6 +85,11 @@ class _BlockingOnManager:
def __exit__(self, *args, **kwargs):
"""Remove self.lock from this thread's _blocking_on list."""
self.blocked_on.remove(self.lock)
+ if len(self.blocked_on) == 0:
+ # gh-101766: glboal cache should be cleaned-up
+ # if there is no more _blocking_on for this thread.
+ del _blocking_on[self.thread_id]
+ del self.blocked_on
class _DeadlockError(RuntimeError):