Skip to content

Commit f482ade

Browse files
authored
gh-101766: Fix refleak for _BlockingOnManager resources from test suite level (gh-101988)
1 parent 072011b commit f482ade

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: Lib/importlib/_bootstrap.py

-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ 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
9388

9489

9590
class _DeadlockError(RuntimeError):

Diff for: Lib/test/test_importlib/test_locks.py

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class ModuleLockAsRLockTests:
3333
test_repr = None
3434
test_locked_repr = None
3535

36+
def tearDown(self):
37+
for splitinit in init.values():
38+
splitinit._bootstrap._blocking_on.clear()
39+
40+
3641
LOCK_TYPES = {kind: splitinit._bootstrap._ModuleLock
3742
for kind, splitinit in init.items()}
3843

0 commit comments

Comments
 (0)