Some Runtime Finalization Constraints Are Not Enforced Nor Documented
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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