]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101766: Fix refleak for _BlockingOnManager resources from test suite level (gh...
authorDong-hee Na <donghee.na@python.org>
Fri, 17 Feb 2023 15:18:47 +0000 (00:18 +0900)
committerGitHub <noreply@github.com>
Fri, 17 Feb 2023 15:18:47 +0000 (00:18 +0900)
Lib/importlib/_bootstrap.py
Lib/test/test_importlib/test_locks.py

index 1ef7b6adb04434ef3c1948d2ee9c5547899444d8..bebe7e15cbce6742c76a2bcee6dc40886bbc9564 100644 (file)
@@ -85,11 +85,6 @@ 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):
index 56d73c496e6bbb01cda23eb287ccb0b2640e1db2..ba9cf51c261d52a483a838d32ceb91ddcc7b490c 100644 (file)
@@ -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()}