Skip to content

Commit 6ff177a

Browse files
committedFeb 14, 2023
gh-101766: Fix refleak for _BlockingOnManager resources
1 parent eb0c485 commit 6ff177a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎Lib/importlib/_bootstrap.py

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ 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]
8892

8993

9094
class _DeadlockError(RuntimeError):

0 commit comments

Comments
 (0)