René's URL Explorer Experiment


Title: `sys.remote_exec()` can fail when subinterpreters exist · Issue #159194 · python/cpython · GitHub

Open Graph Title: `sys.remote_exec()` can fail when subinterpreters exist · Issue #159194 · python/cpython

X Title: `sys.remote_exec()` can fail when subinterpreters exist · Issue #159194 · python/cpython

Description: Bug report When there's a subinterpreters, sys.remote_exec() can fail to find the main thread or run the script in the subinterpreter. Reproduction An idle subinterpreter makes a previously successful call fail: import os, sys, tempfile ...

Open Graph Description: Bug report When there's a subinterpreters, sys.remote_exec() can fail to find the main thread or run the script in the subinterpreter. Reproduction An idle subinterpreter makes a previously success...

X Description: Bug report When there's a subinterpreters, sys.remote_exec() can fail to find the main thread or run the script in the subinterpreter. Reproduction An idle subinterpreter makes a previously suc...

Opengraph URL: https://github.com/python/cpython/issues/159194

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`sys.remote_exec()` can fail when subinterpreters exist","articleBody":"### Bug report\n\nWhen there's a subinterpreters, `sys.remote_exec()` can fail to find the main thread or run the script in the subinterpreter.\n\n## Reproduction\n\nAn idle subinterpreter makes a previously successful call fail:\n\n```python\nimport os, sys, tempfile\nfrom pathlib import Path\nfrom concurrent import interpreters\n\nwith tempfile.TemporaryDirectory() as directory:\n    script = Path(directory) / \"remote.py\"\n    script.write_text(\"print('script executed')\")\n    sys.remote_exec(os.getpid(), str(script))\n    interp = interpreters.create()\n    try:\n        sys.remote_exec(os.getpid(), str(script))\n    except RuntimeError as error:\n        print(type(error).__name__ + \": \" + str(error))\n    finally:\n        interp.close()\n```\n\nOutput on `9028df36bb9`:\n\n```bash\nmaurycy@gimel cpython (main 9028df3) % ./python.exe /tmp/re1_repro.py\nscript executed\nRuntimeError: Can't find the main thread in the remote process\nmaurycy@gimel cpython (main 9028df3) %\n```\n\nBoth `sys.remote_exec` calls should execute the script.\n\nAlso, a running subinterpreter receives the script instead of the main interpreter.\n\nThis example calls `remote_exec()` from the subinterpreter itself:\n\n```python\nimport os, sys, tempfile\nfrom pathlib import Path\nfrom concurrent import interpreters\n\nwith tempfile.TemporaryDirectory() as directory:\n    script = Path(directory) / \"remote.py\"\n    script.write_text(\"from concurrent import interpreters; \"\n                      \"print('executed in interpreter', interpreters.get_current().id)\")\n    interp = interpreters.create()\n    try:\n        interp.exec(f\"import os, sys; sys.remote_exec(os.getpid(), {str(script)!r})\")\n    finally:\n        interp.close()\n```\n\nOutput on `9028df36bb9`:\n\n```text\nmaurycy@gimel cpython (main 9028df3) % ./python.exe /tmp/re2_repro.py\nexecuted in interpreter 1\nmaurycy@gimel cpython (main 9028df3) %\n```\n\nI believe the expected is `0`:\n\n\n\n## Cause\n\nNew interpreters enter the start of `_PyRuntime.interpreters`. The list head is the newest interpreter, not the main interpreter:\n\nhttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/pystate.c#L740\n\nAns `send_exec_to_proc_handle()` reads only the head:\n\nhttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/remote_debugging.c#L125-L133\n\nFor `tid == 0`, which `sys.remote_exec()` passes, it uses that interpreter's `threads_main`:\n\nhttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/remote_debugging.c#L202-L216\n\nAn idle subinterpreter has no main thread state. A running subinterpreter has one, but I think (TBD) it'd belong to the wrong interpreter.\n\nThe HOWTO repeats the same lookup for the main thread:\n\nhttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Doc/howto/remote_debugging.rst#L498-L532\n\nI'm working on the fix.\n\n### CPython versions tested on:\n\nCPython main branch (likely backport to 3.14 and 3.15)\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159259\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-10-11T19:55:37Z","url":"https://github.com/python/cpython/issues/159194"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e5ad70f4-980e-1694-597c-c46cd266cee4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD4AE:A71F9:3C2631A:4C057CB:6B023C3D
html-safe-nonce5cbb879ec4a965319c5c50ca9b841694267e7005a52c3af891166b92de9d3c03
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEFFOkE3MUY5OjNDMjYzMUE6NEMwNTdDQjo2QjAyM0MzRCIsInZpc2l0b3JfaWQiOiIxNjE5NDM3OTQyMTA1ODQ4ODkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc4f3da3d3cf696a2268ce64bb7341d3c671d66a0e4d0bb3d09294f82bf2dd003
hovercard-subject-tagissue:5804619269
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/159194/issue_layout
twitter:imagehttps://opengraph.githubassets.com/28160251ab6539deb28d5496be9722403f6534bc704c5b5d1fee4ebf81309d14/python/cpython/issues/159194
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/28160251ab6539deb28d5496be9722403f6534bc704c5b5d1fee4ebf81309d14/python/cpython/issues/159194
og:image:altBug report When there's a subinterpreters, sys.remote_exec() can fail to find the main thread or run the script in the subinterpreter. Reproduction An idle subinterpreter makes a previously success...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemaurycy
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/159194#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159194
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159194
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/159194
Reloadhttps://github.com/python/cpython/issues/159194
Reloadhttps://github.com/python/cpython/issues/159194
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159194
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159194
#159259https://github.com/python/cpython/pull/159259
sys.remote_exec() can fail when subinterpreters existhttps://github.com/python/cpython/issues/159194#top
#159259https://github.com/python/cpython/pull/159259
https://github.com/maurycy
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/maurycy
maurycyhttps://github.com/maurycy
on Oct 11, 2026https://github.com/python/cpython/issues/159194#issue-5804619269
cpython/Python/pystate.chttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/pystate.c#L740
9028df3https://github.com/python/cpython/commit/9028df36bb9e2942b19164f6708f9cf8a55c5ce9
cpython/Python/remote_debugging.chttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/remote_debugging.c#L125-L133
9028df3https://github.com/python/cpython/commit/9028df36bb9e2942b19164f6708f9cf8a55c5ce9
cpython/Python/remote_debugging.chttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Python/remote_debugging.c#L202-L216
9028df3https://github.com/python/cpython/commit/9028df36bb9e2942b19164f6708f9cf8a55c5ce9
cpython/Doc/howto/remote_debugging.rsthttps://github.com/python/cpython/blob/9028df36bb9e2942b19164f6708f9cf8a55c5ce9/Doc/howto/remote_debugging.rst#L498-L532
9028df3https://github.com/python/cpython/commit/9028df36bb9e2942b19164f6708f9cf8a55c5ce9
gh-159194: Fix sys.remote_exec() with a subinterpreter #159259https://github.com/python/cpython/pull/159259
maurycyhttps://github.com/maurycy
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Oct 11, 2026https://github.com/python/cpython/issues/159194#event-33001186396
https://github.com/maurycy
maurycyhttps://github.com/maurycy
on Oct 11, 2026https://github.com/python/cpython/issues/159194#issuecomment-6113089725
@pablogsalhttps://github.com/pablogsal
https://github.com/sharktide
sharktidehttps://github.com/sharktide
on Oct 12, 2026https://github.com/python/cpython/issues/159194#issuecomment-6126736256
https://github.com/sharktide
sharktidehttps://github.com/sharktide
on Oct 12, 2026https://github.com/python/cpython/issues/159194#issuecomment-6126876567
picnixzhttps://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Oct 12, 2026https://github.com/python/cpython/issues/159194#event-33073790266
https://github.com/pablogsal
pablogsalhttps://github.com/pablogsal
on Oct 12, 2026https://github.com/python/cpython/issues/159194#issuecomment-6130823768
@maurycyhttps://github.com/maurycy
https://github.com/maurycy
maurycyhttps://github.com/maurycy
on Oct 12, 2026https://github.com/python/cpython/issues/159194#issuecomment-6130889571
@pablogsalhttps://github.com/pablogsal
pablogsalhttps://github.com/pablogsal
maurycyhttps://github.com/maurycy
on Oct 12, 2026https://github.com/python/cpython/issues/159194#event-33074517211
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159194#event-33592158087
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159194
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159194
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159194#event-33592177424
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159194
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159194
maurycyhttps://github.com/maurycy
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.