Skip to content

Commit 775f881

Browse files
authored
gh-101766: Fix refleak for _BlockingOnManager resources (gh-101942)
1 parent 3c0a31c commit 775f881

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/importlib/_bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def __enter__(self):
8585
def __exit__(self, *args, **kwargs):
8686
"""Remove self.lock from this thread's _blocking_on list."""
8787
self.blocked_on.remove(self.lock)
88+
if len(self.blocked_on) == 0:
89+
# gh-101766: glboal cache should be cleaned-up
90+
# if there is no more _blocking_on for this thread.
91+
del _blocking_on[self.thread_id]
92+
del self.blocked_on
8893

8994

9095
class _DeadlockError(RuntimeError):

0 commit comments

Comments
 (0)