Skip to content

Conversation

@jborean93
Copy link
Contributor

Expose a public API that can retrieve the processed CLI options for the current process launched through the debugpy CLI. This enables code to be able to retrieve options like the port and adapter access token to be used for launching their own child process' that can be debugged.

Expose a public API that can retrieve the processed CLI options for the
current process launched through the debugpy CLI. This enables code to
be able to retrieve options like the port and adapter access token to be
used for launching their own child process' that can be debugged.
@jborean93 jborean93 requested a review from a team as a code owner July 15, 2025 01:49
# The CLI entrypoint was not called so there are no options present.
return None

# We don't return the actual options object because we don't want callers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, good idea

@rchiodo
Copy link
Contributor

rchiodo commented Jul 15, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jborean93
Copy link
Contributor Author

jborean93 commented Jul 15, 2025

I'll look at the CI failures and try and fix them up but I just wanted to float an alternative idea to see if you prefer that.

Instead of exposing the CLI options like this an alternative would be to extract the debugging information at runtime from pydevd instead. That way it would also work for debugging sessions started with something like

# src/debugpy/server/api.py

@dataclasses.dataclass(frozen=True)
class DebugInfo:
    client: str
    port: int
    access_token: str | None


def get_debug_info():
    ensure_logging()
    log.debug("get_debug_info()")

    info = pydevd.SetupHolder.setup

    return DebugInfo(
        client=info['client']
        port=info['port']
        access_token=info['access-token']
    )

The advantages here is that it only exposes what you want to expose from pydevd and works for both a session started from the CLI as well as through the API. The downside is you are potentially at the mercy of exposing how pydevd works.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 15, 2025

The advantages here is that it only exposes what you want to expose from pydevd and works for both a session started from the CLI as well as through the API. The downside is you are potentially at the mercy of exposing how pydevd works.

I think I prefer your original idea. I'd guess that somebody starting using the API would know what parameters they passed to it (so they wouldn't need this api?) And not super happy about pydevd knowledge bleeding upwards.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 15, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo rchiodo merged commit 1aff9aa into microsoft:main Jul 15, 2025
24 checks passed
@jborean93 jborean93 deleted the cli-args-api branch July 15, 2025 22:57
@jborean93
Copy link
Contributor Author

jborean93 commented Jul 15, 2025

Thanks, looking forward to the next release!

Edit: just noticed 1.8.15 was just pushed out, will have to wait for the next one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants