Associate thread-local data/context with a faulthandler traceback

Đang mở
#98,825 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.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với mô-đun faulthandler và xem lại cuộc thảo luận Python-ideas được liên kết để hiểu context cục bộ theo thread được đề xuất cùng các ràng buộc của nó. So sánh các ví dụ về hàm và context manager với đầu ra traceback được yêu cầu; để hoàn thành, cần có một API và hành vi đã được thống nhất cho việc liên kết và phát ra context.

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

Mô tả

type-feature

Feature or enhancement

I’d like to be able to associate a thread-local string with the faulthandler module.

Pitch

The faulthandler module is invaluable for tracking down segfaults in native code, however it is really lacking the ability to add some kind of useful breadcumb to aide debugging. Imagine you are running a large-scale distributed job over tens of millions of images and a single one causes opencv to segfault reliably. This can be very difficult to track down.

It would be very useful to be able to add a string (limited by size) via the faulthandler module that is outputted along with the traceback. For example:

for image in millions_of_images():
    faulthandler.context(f'{image.id=}')
    segfaulty_function(image)

# Or maybe:
for image in millions_of_images():
    with faulthandler.context(f'{image.id=}'):
        segfaulty_function(image)

The traceback might be something like:

Fatal Python error: Segmentation fault

Current thread 0x00007fb899f39700 (most recent call first):
  .... (traceback)
Segmentation fault
Context: image_id=foo

You could of course add logging to this function to print out the image ID before you run it through segfaulty_function, but if you're running this at high volume on a huge number of machines, this becomes a bit of an overhead, and it doesn't handle multiple threads running the function well.

Previous discussion

This is lifted from the following thread on Python-ideas: https://mail.python.org/archives/list/python-ideas@python.org/message/BG36W24KEEX4YJA7CZ3PGW4ISZGVXMH6/

Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

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.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

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.