Skip to content
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

gh-106176: Fix reference leak in importlib/_bootstrap.py #106207

Closed
wants to merge 1 commit into from
Closed
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
gh-106176: Fix reference leak in importlib/_bootstrap.py
  • Loading branch information
Eclips4 committed Jun 28, 2023
commit 5328e32d84aea4008d00895959ace5af2d2293a4
2 changes: 2 additions & 0 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ 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 not self.blocked_on:
del _blocking_on[self.thread_id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just have one question, is this always true?

assert self.blocked_on is _blocking_on[self.thread_id]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, if it were sometimes is not true, self.blocked_on.remove(...) will fail, no?
Though, currently test suite didn't failed with new assert check.

Copy link
Member

@sunmy2019 sunmy2019 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #101942 (comment)

It may not be True under certain circumstances.



class _DeadlockError(RuntimeError):
Expand Down
Loading