diff options
author | Dong-hee Na <donghee.na@python.org> | 2023-02-17 10:14:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-17 10:14:07 (GMT) |
commit | 775f8819e319127f9bfb046773b74bcc62c68b6a (patch) | |
tree | 9149c11f8825048b4fcacf0aed98da659e7bb3e6 | |
parent | 3c0a31cbfd1258bd96153a007dd44a96f2947dbf (diff) | |
download | cpython-775f8819e319127f9bfb046773b74bcc62c68b6a.zip cpython-775f8819e319127f9bfb046773b74bcc62c68b6a.tar.gz cpython-775f8819e319127f9bfb046773b74bcc62c68b6a.tar.bz2 |
gh-101766: Fix refleak for _BlockingOnManager resources (gh-101942)
-rw-r--r-- | Lib/importlib/_bootstrap.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index bebe7e1..1ef7b6a 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -85,6 +85,11 @@ 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): |