Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Support debugging of indirect child processes.

オープン
#1,503 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
devtools

調査の方向性

まず、言及されているエントリポイント debugpy.server.cli.options、debugpy.server.api、debugpy.connect を確認し、既存の直接の子プロセスに対するマルチプロセス対応と比較します。間接的な非 Python プロセスを介してセッションコンテキストを引き渡すための公式な API 境界を定義します。示されている多段階のワーカーツリーが実装の詳細に依存せず接続できれば完了です。

索引モデルが 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時間
マージ済み PR(30日)
1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/debugpy のほかの issue

microsoft/debugpy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。