PyMutex re-entrancy not documented, confusing existing doc
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Documentation
The doc for PyMutex is very unclear if the mutex is re-entrant. Can PyMutex_Lock be called multiple times in the same thread? Do there have to be an equal number of PyMutex_Unlock calls?
The PyMutex_Lock doc says it will succeed if the thread already has the lock. PyMutex_Unlock makes no mention of it having to be called in the same thread, or if any thread is okay.
Elsewhere it says the mutex is one byte, which is not enough to do any form of counting.
The relevance is that I have C code wrapping a library and that library can make callbacks. That means there are multiple paths through the call stack. A re-entrant counting mutex would work perfectly, and it is impossible to use a non-counted lock in that scenario, short of implementing another layer of locking to do the counting.
Linked PRs
- gh-146543
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 C 同步文档中的 PyMutex API 参考开始,并查看链接的 PR gh-146543。确定重复调用 PyMutex_Lock 时文档所规定的行为,以及 PyMutex_Unlock 所需的线程和调用次数,然后更新文档,明确说明这些规则。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100