René's URL Explorer Experiment


Title: gh-135953: Properly obtain main thread identifier in Gecko Collector by flowln · Pull Request #146045 · python/cpython · GitHub

Open Graph Title: gh-135953: Properly obtain main thread identifier in Gecko Collector by flowln · Pull Request #146045 · python/cpython

X Title: gh-135953: Properly obtain main thread identifier in Gecko Collector by flowln · Pull Request #146045 · python/cpython

Description: Since running a profiler via CLI (python -m profiling.sampling run) spawns a new subprocess where the actual user-specified code will run, a call to threading.main_thread() in the collector's process will not return the profiled process's main thread. To combat this, we add a new attribute to the returned InterpreterState for the sampled stack frames, which takes the id of the thread_main member from the original sampled interpreter's state. This allows the main thread to be highlighted on Firefox Profiler: Issue: gh-135953

Open Graph Description: Since running a profiler via CLI (python -m profiling.sampling run) spawns a new subprocess where the actual user-specified code will run, a call to threading.main_thread() in the collector's p...

X Description: Since running a profiler via CLI (python -m profiling.sampling run) spawns a new subprocess where the actual user-specified code will run, a call to threading.main_thread() in the collector&#39...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:17d11608-f2a4-5a97-6afb-05cd1b2e4b2a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9D4A:3F3AF6:4FC001B:6EE9254:6A50F3B9
html-safe-nonce04efa32138810200e898f34dc14951fe18544a4ab019848d3cdc979310fc66ea
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDRBOjNGM0FGNjo0RkMwMDFCOjZFRTkyNTQ6NkE1MEYzQjkiLCJ2aXNpdG9yX2lkIjoiODI1Mjk3NDE1NDM0NjcyMjIzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac205ef657a8e5e5c46f1dbefd8f21dce700b1164eca22de3a1211fe59a20777b4
hovercard-subject-tagpull_request:3407262519
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/146045/files
twitter:imagehttps://avatars.githubusercontent.com/u/9145768?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/9145768?s=400&v=4
og:image:altSince running a profiler via CLI (python -m profiling.sampling run) spawns a new subprocess where the actual user-specified code will run, a call to threading.main_thread() in the collector's p...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838
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
release5ec60191a48933536a90c8a19f47142fcd0d4739
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/146045/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F146045%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%2F146045%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/146045/files
Reloadhttps://github.com/python/cpython/pull/146045/files
Reloadhttps://github.com/python/cpython/pull/146045/files
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k 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
pablogsalhttps://github.com/pablogsal
python:mainhttps://github.com/python/cpython/tree/main
flowln:fix_tachyon_main_threadhttps://github.com/flowln/cpython/tree/fix_tachyon_main_thread
Conversation 13 https://github.com/python/cpython/pull/146045
Commits 7 https://github.com/python/cpython/pull/146045/commits
Checks 48 https://github.com/python/cpython/pull/146045/checks
Files changed https://github.com/python/cpython/pull/146045/files
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
gh-135953: Properly obtain main thread identifier in Gecko Collector https://github.com/python/cpython/pull/146045/files#top
Show all changes 7 commits https://github.com/python/cpython/pull/146045/files
4a82ac9 profiling(Gecko): Properly obtain main thread identifier flowln Mar 17, 2026 https://github.com/python/cpython/pull/146045/commits/4a82ac9d678fccb486b113e2a25462e13a5996bf
8920f2f profiling(gecko): take last thread as main thread instead of first one flowln Mar 17, 2026 https://github.com/python/cpython/pull/146045/commits/8920f2f062bf3c93090c5ed2d1fab079baa6645f
d9b0a79 profiling(Gecko): check if thread list is not empty before accessing it flowln Mar 17, 2026 https://github.com/python/cpython/pull/146045/commits/d9b0a79ba7a170cae4404ad8ddea0a32c102fae4
f186d3f profiling(gecko): retrieve main thread id directly from interpreter s… flowln Mar 21, 2026 https://github.com/python/cpython/pull/146045/commits/f186d3ffedcb6806ebaa4a791c09376d53cd0786
5849aad profiling(gecko): add main_thread_id to MockInterpreter and add check… flowln Mar 21, 2026 https://github.com/python/cpython/pull/146045/commits/5849aad7269517895444a0b4215c0319cab56411
ad5b78c profiling(gecko): use status flag for main thread instead of Interpre… pablogsal Mar 22, 2026 https://github.com/python/cpython/pull/146045/commits/ad5b78c2bd878c43f31e547f20660a2c7c8335e4
acbbd15 Add news entry pablogsal Mar 22, 2026 https://github.com/python/cpython/pull/146045/commits/acbbd15cb766769c32f00abf763529f2bca596b2
Clear filters https://github.com/python/cpython/pull/146045/files
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
constants.py https://github.com/python/cpython/pull/146045/files#diff-1dbdfd7faa263b65ad4a3916ada4649fa57b4b487e91ce085aa5ea6bf2dda345
gecko_collector.py https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
test_binary_format.py https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
test_collectors.py https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
2026-03-22-00-00-00.gh-issue-135953.IptOwg.rst https://github.com/python/cpython/pull/146045/files#diff-c65ad56c2567f7b35bf68c9d8f6c2fc4b38160e093453807723289d1915586c7
_remote_debugging.h https://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
module.c https://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
threads.c https://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L557
Lib/profiling/sampling/constants.pyhttps://github.com/python/cpython/pull/146045/files#diff-1dbdfd7faa263b65ad4a3916ada4649fa57b4b487e91ce085aa5ea6bf2dda345
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Lib/profiling/sampling/constants.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-1dbdfd7faa263b65ad4a3916ada4649fa57b4b487e91ce085aa5ea6bf2dda345
https://github.com/python/cpython/pull/146045/files#diff-1dbdfd7faa263b65ad4a3916ada4649fa57b4b487e91ce085aa5ea6bf2dda345
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L557
Lib/profiling/sampling/gecko_collector.pyhttps://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Lib/profiling/sampling/gecko_collector.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/pull/146045/files#diff-9f0310d53a6ad09d9b7b291d3db2faaa3f441fd926b249406921720be5ac4df7
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L558
Lib/test/test_profiling/test_sampling_profiler/test_binary_format.pyhttps://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Lib/test/test_profiling/test_sampling_profiler/test_binary_format.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
https://github.com/python/cpython/pull/146045/files#diff-bd4b914717c4ce7ddb2e29a91a71fdba550983ce9cea09b1ee06847b128d71b6
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L558
Lib/test/test_profiling/test_sampling_profiler/test_collectors.pyhttps://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Lib/test/test_profiling/test_sampling_profiler/test_collectors.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
https://github.com/python/cpython/pull/146045/files#diff-8436f3f406ad4ede0e395a9a742e325aee99447b5cdac2a56839230c0e519bd2
Misc/NEWS.d/next/Tools-Demos/2026-03-22-00-00-00.gh-issue-135953.IptOwg.rsthttps://github.com/python/cpython/pull/146045/files#diff-c65ad56c2567f7b35bf68c9d8f6c2fc4b38160e093453807723289d1915586c7
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Misc/NEWS.d/next/Tools-Demos/2026-03-22-00-00-00.gh-issue-135953.IptOwg.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L338
Modules/_remote_debugging/_remote_debugging.hhttps://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Modules/_remote_debugging/_remote_debugging.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/pull/146045/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L338
Modules/_remote_debugging/module.chttps://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Modules/_remote_debugging/module.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
https://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
https://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
https://github.com/python/cpython/pull/146045/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L338
Modules/_remote_debugging/threads.chttps://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
View file https://github.com/flowln/cpython/blob/acbbd15cb766769c32f00abf763529f2bca596b2/Modules/_remote_debugging/threads.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/146045/{{ revealButtonHref }}
https://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
https://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
https://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
https://github.com/python/cpython/pull/146045/files#diff-6cb0e37d99f0b76992ce6170feb1853dc26762bb1fd7e12ef30436b71198b8bb
Please reload this pagehttps://github.com/python/cpython/pull/146045/files
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.