Skip to content

gh-101766: Fix refleak for _BlockingOnManager resources at test-suite level #101987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ 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 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):
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_importlib/test_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ModuleLockAsRLockTests:
test_repr = None
test_locked_repr = None

def tearDown(self):
for splitinit in init.values():
splitinit._bootstrap._blocking_on.clear()


LOCK_TYPES = {kind: splitinit._bootstrap._ModuleLock
for kind, splitinit in init.items()}

Expand Down