Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support debugging of indirect child processes.

Đang mở
#1,503 1 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
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng việc xem xét các entry point được đề cập là debugpy.server.cli.options, debugpy.server.api và debugpy.connect, sau đó so sánh chúng với khả năng hỗ trợ multiprocess hiện có cho các tiến trình con trực tiếp. Xác định ranh giới API chính thức để truyền ngữ cảnh phiên qua các tiến trình gián tiếp không phải Python; được coi là hoàn thành khi cây worker nhiều cấp được minh họa có thể kết nối mà không dựa vào các chi tiết triển khai.

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

Mô tả

bug

While debugpy natively supports multiprocess debugging, this works only for directly launched child processes.
Sometimes, though, there may be several levels on non-Python processes between the main process and the child one needs to debug. I am hitting this limitation while trying to debug a user-defined function, that runs in the context of a PySpark worker process. The process tree looks like this:

<python process hosting my main program>
 └ <pyspark process>
    └ <yet another pyspark process>
       ├ <python worker process hosting the UDFs>
       ├ <python worker process hosting the UDFs>
       ├ ...
       └ <python worker process hosting the UDFs>

After spelunking the innards of debugpy for a few hours, I've managed to come up with this code:

import pickle
import os
import debugpy

def capture_session_context():
    """To be called in the main process to capture context of the current debugpy session."""
    options = debugpy.server.cli.options
    context = pickle.dumps((options.address, options.adapter_access_token, os.getpid()), 0)
    os.environ["DEBUGPY_CONTEXT"] = context.decode('ascii')

def connect_to_session():
    """To be called in a worker process to connect to the parent session."""
    context = os.environ['DEBUGPY_CONTEXT'].encode('ascii')
    address, token, ppid = pickle.loads(context)
    from debugpy.server import api
    api.pydevd.SetupHolder.setup = {"ppid": ppid}
    debugpy.connect(address, access_token=token)

Obviously, this hack uses a bunch of implementation details. It would be nice if this scenario was officially supported.
(I mean exposing official APIs similar to the above, not that debugpy should support PySperk specifically.

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

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 microsoft/debugpy

Tất cả issue của microsoft/debugpy

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.