Some Runtime Finalization Constraints Are Not Enforced Nor Documented
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
There are a few technical constraints on calling Py_Finalize() currently aren't enforced, well-documented, or widely recognized. This is partly due to the relatively small number of embedders and the even smaller number of them that might violate the constraints through the use of threads or subinterpreters.
The constraints are:
- should be called only in the main thread
- should be called only with the main interpreter active
- should be called only using the same thread state used for
Py_Initialize()
(That last one is potentially less critical.)
There are several reasons these matter:
- the main thread of the main interpreter has a special role in the runtime's lifecycle
- the main thread of the main interpreter has unique responsibilities that must be synchronized with finalization
- conceptually, runtime lifecycle is an app-level function, and the app is typically driven through the "main" thread
The constraints should be documented, tested, and (possibly) enforced.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-120839
- gh-120840
- gh-120841
- gh-120852
- gh-120853
- gh-121010
- gh-121013
- gh-121063
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先跟踪 Py_Finalize() 入口点,并查看链接的 PR gh-120839、gh-120840、gh-120841、gh-120852、gh-120853、gh-121010、gh-121013 和 gh-121063。完成的标准是:主线程、主解释器和初始化线程状态的约束已记录、有测试覆盖,并且可能已得到强制执行。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 20/100