Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Support debugging of indirect child processes.

Open
#1,503 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
devtools

Research direction

Start by reviewing the mentioned debugpy.server.cli.options, debugpy.server.api, and debugpy.connect entry points, then compare them with the existing direct-child multiprocess support. Define the official API boundary for carrying session context through indirect non-Python processes; done means the shown multi-level worker tree can connect without relying on implementation details.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
2.5k
Forks
202
Avg merge
5d 1h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/debugpy

All issues in microsoft/debugpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.