Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support debugging of indirect child processes.

未关闭
#1,503 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
devtools

调研方向

首先检查提到的入口点 debugpy.server.cli.options、debugpy.server.api 和 debugpy.connect,然后将它们与现有的直接子进程多进程支持进行比较。定义通过间接的非 Python 进程传递会话上下文的官方 API 边界;当所示的多级 worker 树能够在不依赖实现细节的情况下连接时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
2.5k
派生
202
平均合并
5 天 1 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/debugpy 的其他 Issue

查看 microsoft/debugpy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。