python / python/cpython

`_PyEval_SetTrace` is no longer available in C API since 3.13

Đang mở
#127,748 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

3.13 topic-C-API type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Xem xét việc loại bỏ được mô tả trong PR 108433 và so sánh các API PyEval_SetTrace và PyEval_SetTraceAllThreads hiện có với hành vi theo từng thread được yêu cầu. Sau đó, điều tra xem sys.monitoring có thể giới hạn các sự kiện trong một thread hay không và liệu một extension có phải là lựa chọn thay thế phù hợp hay không. Hoàn tất khi đã xác định được hướng API rõ ràng, với sự đồng thuận của maintainer về việc khôi phục hoặc một cách tiếp cận được hỗ trợ khác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, python
Lĩnh vực
api, compilers
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.