Support debugging of indirect child processes.
还没有人认领这个 Issue。
评估
调研方向
首先检查提到的入口点 debugpy.server.cli.options、debugpy.server.api 和 debugpy.connect,然后将它们与现有的直接子进程多进程支持进行比较。定义通过间接的非 Python 进程传递会话上下文的官方 API 边界;当所示的多级 worker 树能够在不依赖实现细节的情况下连接时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/debugpy 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
documentation
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 68/100
查看 microsoft/debugpy 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100