René's URL Explorer Experiment


Title: bpo-33978: close resources before deletion of logging handlers by tirkarthi · Pull Request #8008 · python/cpython · GitHub

Open Graph Title: bpo-33978: close resources before deletion of logging handlers by tirkarthi · Pull Request #8008 · python/cpython

X Title: bpo-33978: close resources before deletion of logging handlers by tirkarthi · Pull Request #8008 · python/cpython

Description: Close the file handlers before deleting the logging handlers so that there is no resource warning. Since the handlers are a weakreference I tried to close them by calling self.close on __del__ but not all handlers have the lock attribute which resulted in AttributeError. shutdown handles the AttributeError and other scenarios but it will be a much cleaner if we close the handlers during weakref deletion instead of calling shudown which might miss some places. Additionally shutdown is also registered at exit which should clean up the current handlers I hope but doesn't handle the ones that were deleted. Attached tests and a NEWS entry. Kindly correct me if I am wrong on the approach since this is my first non-easy PR and I would like some help on this fix hoping the fix will not be much complex. Thanks https://bugs.python.org/issue33978

Open Graph Description: Close the file handlers before deleting the logging handlers so that there is no resource warning. Since the handlers are a weakreference I tried to close them by calling self.close on __del__ but ...

X Description: Close the file handlers before deleting the logging handlers so that there is no resource warning. Since the handlers are a weakreference I tried to close them by calling self.close on __del__ but ...

Opengraph URL: https://github.com/python/cpython/pull/8008

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:277b2705-0ed2-7182-0420-dfd3f550d61b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9BEE:306885:28E6751:3A45EE0:6A59030B
html-safe-nonce01563cf346450f28e9f8778336b263bfdd5968375ef5dde3a49d76498afaed0c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkVFOjMwNjg4NToyOEU2NzUxOjNBNDVFRTA6NkE1OTAzMEIiLCJ2aXNpdG9yX2lkIjoiNDEwMTQyNTc5MzU2OTcxOTA1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3187bae32287564fad7308731d46dc4c091a7fed2b4c7cda2e024ef86c54da5f
hovercard-subject-tagpull_request:198304703
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/8008/files
twitter:imagehttps://avatars.githubusercontent.com/u/3972343?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3972343?s=400&v=4
og:image:altClose the file handlers before deleting the logging handlers so that there is no resource warning. Since the handlers are a weakreference I tried to close them by calling self.close on __del__ but ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9842457e8d7e3b2e1635a63af28da35614845510
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/8008/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F8008%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F8008%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/8008/files
Reloadhttps://github.com/python/cpython/pull/8008/files
Reloadhttps://github.com/python/cpython/pull/8008/files
Please reload this pagehttps://github.com/python/cpython/pull/8008/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/8008/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
vsajiphttps://github.com/vsajip
python:masterhttps://github.com/python/cpython/tree/master
tirkarthi:bpo33978-close-handlers-before-deletionhttps://github.com/tirkarthi/cpython/tree/bpo33978-close-handlers-before-deletion
Conversation 22 https://github.com/python/cpython/pull/8008
Commits 7 https://github.com/python/cpython/pull/8008/commits
Checks 0 https://github.com/python/cpython/pull/8008/checks
Files changed https://github.com/python/cpython/pull/8008/files
Please reload this pagehttps://github.com/python/cpython/pull/8008/files
bpo-33978: close resources before deletion of logging handlers https://github.com/python/cpython/pull/8008/files#top
Show all changes 7 commits https://github.com/python/cpython/pull/8008/files
7e6a027 Close resources before deleting logging handlers tirkarthi Jun 29, 2018 https://github.com/python/cpython/pull/8008/commits/7e6a027d505ac5e26ee4e968c43c6b71f1ac634d
d54a3f6 Add NEWS entry tirkarthi Jun 29, 2018 https://github.com/python/cpython/pull/8008/commits/d54a3f6812971b9fe622cac4bc90218f9ae70b14
698abe6 Change NEWS entry tirkarthi Jul 2, 2018 https://github.com/python/cpython/pull/8008/commits/698abe6558a839a3f67ddf1bcf5fbef657d9aed9
9fd2066 Use _clearExistingHandlers to avoid duplicate code tirkarthi Jul 2, 2018 https://github.com/python/cpython/pull/8008/commits/9fd2066abeb81b3958d7073291bc7fc3125c4a88
d986a36 Use mkstemp instead of NamedTemporaryFile tirkarthi Jul 2, 2018 https://github.com/python/cpython/pull/8008/commits/d986a36cf33aace7446e7787badee60733a5d920
4be6fbe Use raw string to avoid unicodeescape error in Windows tirkarthi Jul 2, 2018 https://github.com/python/cpython/pull/8008/commits/4be6fbe9864352a1273c6a1209febd28973cdb4e
b79f8a2 Replace backslash and handle open fd in windows tirkarthi Jul 2, 2018 https://github.com/python/cpython/pull/8008/commits/b79f8a22aac28b79bb5255afcc8da95142245f5f
Clear filters https://github.com/python/cpython/pull/8008/files
Please reload this pagehttps://github.com/python/cpython/pull/8008/files
Please reload this pagehttps://github.com/python/cpython/pull/8008/files
config.py https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
test_logging.py https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
2018-06-29-12-23-34.bpo-33978.y4csIw.rst https://github.com/python/cpython/pull/8008/files#diff-17e08c956240166be0a1ac77cfc0dbe776b8f87ed8096b16cbb0f250660a8af1
Lib/logging/config.pyhttps://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
View file https://github.com/tirkarthi/cpython/blob/b79f8a22aac28b79bb5255afcc8da95142245f5f/Lib/logging/config.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/8008/{{ revealButtonHref }}
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
https://github.com/python/cpython/pull/8008/files#diff-6b781e2294c88b6a18e9be5d536be2afb74f22593ec5be3de3bc3b507d955755
Lib/test/test_logging.pyhttps://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
View file https://github.com/tirkarthi/cpython/blob/b79f8a22aac28b79bb5255afcc8da95142245f5f/Lib/test/test_logging.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/8008/{{ revealButtonHref }}
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
https://github.com/python/cpython/pull/8008/files#diff-bc15bb717afb8343ceee4cd4219559dc397092dcde20271f6e8708c2b132976f
Misc/NEWS.d/next/Library/2018-06-29-12-23-34.bpo-33978.y4csIw.rsthttps://github.com/python/cpython/pull/8008/files#diff-17e08c956240166be0a1ac77cfc0dbe776b8f87ed8096b16cbb0f250660a8af1
View file https://github.com/tirkarthi/cpython/blob/b79f8a22aac28b79bb5255afcc8da95142245f5f/Misc/NEWS.d/next/Library/2018-06-29-12-23-34.bpo-33978.y4csIw.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/8008/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.