`_PyEval_SetTrace` is no longer available in C API since 3.13
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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