-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-37788: Fix a reference leak if a thread is not joined #15228
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
Conversation
Add threading.Thread.__del__() method to ensure that the thread state lock is removed from the _shutdown_locks list when a thread completes.
I have two points:
|
@pitrou, @pablogsal, @methane, @serhiy-storchaka: my https://bugs.python.org/issue36402 fix introduced a memory leak when a thread is started but never joined explicitly. This PR 8000 adds a destructor to thread.Thread to fix the regression. What do you think? We need to fix 3.7, 3.8 and master branches, I would prefer to use the same fix in all branches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @vstinner !
|
That hasn't been the case in a long time, except if you're talking about Python 2.7. |
So we can now get rid of |
Hmm... probably? I'll let you figure out :-) |
That code was added after 2.7, it was not the first attempt to fix some issues with tempfile, and only it was successful. |
That's no longer the case since @pitrou's PEP 442 https://www.python.org/dev/peps/pep-0442/ (finalizers). |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8. |
I'm having trouble backporting to |
GH-15336 is a backport of this pull request to the 3.7 branch. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-15337 is a backport of this pull request to the 3.8 branch. |
Oh, my change is wrong: it introduced a regression :-(
|
…5228) Add threading.Thread.__del__() method to ensure that the thread state lock is removed from the _shutdown_locks list when a thread completes.
…thonGH-15228)" (pythonGH-15338) This reverts commit d3dcc92.
…5228) Add threading.Thread.__del__() method to ensure that the thread state lock is removed from the _shutdown_locks list when a thread completes.
…thonGH-15228)" (pythonGH-15338) This reverts commit d3dcc92.
…5228) Add threading.Thread.__del__() method to ensure that the thread state lock is removed from the _shutdown_locks list when a thread completes.
…thonGH-15228)" (pythonGH-15338) This reverts commit d3dcc92.
Any movement on fixing this leak when threads aren't "join"-ed? I couldn't upgrade to 3.7 because of this leak, Thanks for all your work on Python, I see you've been quick active in making it better. |
Add threading.Thread.del() method to ensure that the thread state
lock is removed from the _shutdown_locks list when a thread
completes.
https://bugs.python.org/issue37788