`_PyEval_SetTrace` is no longer available in C API since 3.13
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Hello,
Prior 3.13 it was possible to set a trace in a specific thread from another thread by leveraging _PyEval_SetTrace, with pure Python. Now one can either set a trace for the current thread or all the threads using PyEval_SetTrace or PyEval_SetTraceAllThreads.
The change:
https://github.com/python/cpython/pull/108433/files#diff-9e7eb7e81667528dfa3a35bbf32fe622d4721c3c71385ea0ea2250abbd15d545R21
Interestingly, the profiling counterpart seems to be still available in the C API.
The use case I am interested in is a dedicated monitoring thread connected to a distributed observability system. This thread itself should not be traced as it manages tracing for the rest of the process.
Would it be possible to reinstate _PyEval_SetTrace back to the private C API?
Also, the new sys.monitoring module seems to offer a more high-level interface for debuggers and profilers, but it is unclear whether it is possible to limit the events to a certain thread. (unless of course one checks every event which does not seem efficient).
Alternatively, would writing an extension to expose this function be a better approach?
I would greatly appreciate any comments or suggestions regarding this. Thank you!
cc @vstinner
CPython versions tested on:
3.13
Operating systems tested on:
macOS
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
审查 PR 108433 中描述的移除,并将现有的 PyEval_SetTrace 和 PyEval_SetTraceAllThreads API 与所请求的按线程行为进行比较。然后调查 sys.monitoring 是否可以将事件限定到一个线程,以及 extension 是否是合适的替代方案。完成的标准是确定明确的 API 方向,并获得 maintainer 对恢复该功能或采用其他受支持方案的共识。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- api, compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100