René's URL Explorer Experiment


Title: bpo-36867: Create the resource_tracker before launching SharedMemoryManagers by pierreglaser · Pull Request #13276 · python/cpython · GitHub

Open Graph Title: bpo-36867: Create the resource_tracker before launching SharedMemoryManagers by pierreglaser · Pull Request #13276 · python/cpython

X Title: bpo-36867: Create the resource_tracker before launching SharedMemoryManagers by pierreglaser · Pull Request #13276 · python/cpython

Description: TLDR; The resource_tracker needs to be created before SharedMemoryManager processes are launched (which is not the case for managers created using fork) Take this example below: from multiprocessing.managers import SharedMemoryManager from multiprocessing import resource_tracker smm = SharedMemoryManager() smm.start() sl = smm.ShareableList(range(10)) smm.shutdown() This simple and legitimate python scripts results in a very noisy output: /home/pierreglaser/repos/cpython/Lib/multiprocessing/resource_tracker.py:198: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d ' /home/pierreglaser/repos/cpython/Lib/multiprocessing/resource_tracker.py:211: UserWarning: resource_tracker: '/psm_3bfa242d': [Errno 2] No such file or directory: '/psm_3bfa242d' warnings.warn('resource_tracker: %r: %s' % (name, e)) Here is why it happens: smm.start() launches a new manager process. At this point in the main process, no resource_tracker is created if the manager is launched using fork. sl = smm.ShareableList(range(10)) does two things: First, it creates a new shared_memory object from the parent process. At creation, a resource_tracker.register call is done -> resource_tracker.ensure_running is done -> a new resource_tracker process is created. In addition, this resource_tracker now tracks sl. However, since the manager process was created before, it does not know that a new resource_tracker process was just created in the parent process.. Once sl is created, the SharedMemoryManager asks its SharedMemoryTracker ( which lives in the manager process) to track it. smm.shutdown shuts down the manager. It thus asks the SharedMemoryTracker to destroy sl, which it tracks. To do so, it first opens it (using a SharedMemory(name)) call, which itself triggers a resource_tracker.register call -> resource_tracker.ensure_running call in the manager process, where no resource_tracker exists yet! Thus, another ResourceTracker instance /process is created and starts tracking sl immediatly after, it unlinks sl. This sends an unregister call to the newly created resource_tracker. When the script ends however, nothing has been done to tell the original resource_tracker created in the parent process that sl was properly unlinked. The resource_tracker thus thinks a leak happened, and tells the user (first line of my output)). However, there was no leak, as sl was properly unlinked by the manager. Therefore, the cleanup attempt of the resource_tracker fails, resulting the second error. The solution to this problem is simply to create the right before the manager process is created. https://bugs.python.org/issue36867

Open Graph Description: TLDR; The resource_tracker needs to be created before SharedMemoryManager processes are launched (which is not the case for managers created using fork) Take this example below: from multiprocessin...

X Description: TLDR; The resource_tracker needs to be created before SharedMemoryManager processes are launched (which is not the case for managers created using fork) Take this example below: from multiprocessin...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:89e9a680-b854-cf69-4ba7-8abc72582d13
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC700:2D5E27:368F74:48E289:6A51C108
html-safe-nonceaf846d2bd3d31a1bbb67c691117ae739397f67a26ae597518d8c2470aae9f495
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzAwOjJENUUyNzozNjhGNzQ6NDhFMjg5OjZBNTFDMTA4IiwidmlzaXRvcl9pZCI6Ijc2OTkyNjY3OTg3NDc3NjI5NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb18bd16cbdd97fb5f300ae1cfa22c81eb8e919c77356f36bd4a3d7a744c7a6b7
hovercard-subject-tagpull_request:278232026
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/13276/files
twitter:imagehttps://avatars.githubusercontent.com/u/18555600?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/18555600?s=400&v=4
og:image:altTLDR; The resource_tracker needs to be created before SharedMemoryManager processes are launched (which is not the case for managers created using fork) Take this example below: from multiprocessin...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/13276/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F13276%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%2F13276%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/13276/files
Reloadhttps://github.com/python/cpython/pull/13276/files
Reloadhttps://github.com/python/cpython/pull/13276/files
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.7k 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
pitrouhttps://github.com/pitrou
python:masterhttps://github.com/python/cpython/tree/master
pierreglaser:silence-ressource-tracker-with-manager-warninghttps://github.com/pierreglaser/cpython/tree/silence-ressource-tracker-with-manager-warning
Conversation 22 https://github.com/python/cpython/pull/13276
Commits 7 https://github.com/python/cpython/pull/13276/commits
Checks 0 https://github.com/python/cpython/pull/13276/checks
Files changed https://github.com/python/cpython/pull/13276/files
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
bpo-36867: Create the resource_tracker before launching SharedMemoryManagers https://github.com/python/cpython/pull/13276/files#top
Show all changes 7 commits https://github.com/python/cpython/pull/13276/files
0c904b5 create the resource_tracker before the manager pierreglaser May 13, 2019 https://github.com/python/cpython/pull/13276/commits/0c904b5ae78e61b6b0fd3d4cc35e74820c3d09b6
a69d77a 📜🤖 Added by blurb_it. blurb-it[bot] May 13, 2019 https://github.com/python/cpython/pull/13276/commits/a69d77a548668c51af85a0bfddcdee07eec36dd6
6c3e71a TST test that manager reuses its parent tracker pierreglaser May 13, 2019 https://github.com/python/cpython/pull/13276/commits/6c3e71ac6791d1b7b82996c8ec4a642bd10e7586
466b5df CLN brevity pierreglaser May 13, 2019 https://github.com/python/cpython/pull/13276/commits/466b5dfbe035b45d5bb0f1b12a42fbd6d37ae76b
4ef01c8 Fix ResourceWarning in test_shared_memory_SharedMemoryManager_reuses_… pitrou May 13, 2019 https://github.com/python/cpython/pull/13276/commits/4ef01c879095c4e7fa1b5f1f98a139ad6d26d9f8
07aa19c Fix test on Windows pitrou May 13, 2019 https://github.com/python/cpython/pull/13276/commits/07aa19c237404661a9a00b68b204df132f505b05
5194ba4 Merge branch 'master' into silence-ressource-tracker-with-manager-war… pitrou May 13, 2019 https://github.com/python/cpython/pull/13276/commits/5194ba4ead44f0ba09e0d19650d0bed7898d7509
Clear filters https://github.com/python/cpython/pull/13276/files
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
managers.py https://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
_test_multiprocessing.py https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
2019-05-13-13-02-43.bpo-36867.Qh-6mX.rst https://github.com/python/cpython/pull/13276/files#diff-4f5e783c94e930495687ce5363ec1f3777bf1b635551ba7e35f3b15fa830dc5f
Lib/multiprocessing/managers.pyhttps://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
View file https://github.com/pierreglaser/cpython/blob/5194ba4ead44f0ba09e0d19650d0bed7898d7509/Lib/multiprocessing/managers.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/13276/{{ revealButtonHref }}
https://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
https://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
https://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
Please reload this pagehttps://github.com/python/cpython/pull/13276/files
https://github.com/python/cpython/pull/13276/files#diff-9e59d8c837ebf181d34af715ac88bb8a4b6141ec18b703cef2c3c8136391abf7
Lib/test/_test_multiprocessing.pyhttps://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
View file https://github.com/pierreglaser/cpython/blob/5194ba4ead44f0ba09e0d19650d0bed7898d7509/Lib/test/_test_multiprocessing.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/13276/{{ revealButtonHref }}
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/13276/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
Misc/NEWS.d/next/Library/2019-05-13-13-02-43.bpo-36867.Qh-6mX.rsthttps://github.com/python/cpython/pull/13276/files#diff-4f5e783c94e930495687ce5363ec1f3777bf1b635551ba7e35f3b15fa830dc5f
View file https://github.com/pierreglaser/cpython/blob/5194ba4ead44f0ba09e0d19650d0bed7898d7509/Misc/NEWS.d/next/Library/2019-05-13-13-02-43.bpo-36867.Qh-6mX.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/13276/{{ 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.