feat(debug): enable Python debug workflow and debug server integration
Adds an end-to-end Python debug workflow for the extension. Includes a new prepare-debug.ps1 script and a VS Code task. Extends the Python server and extension to coordinate a debug session and safe startup. - Add prepare-debug.ps1 and a VS Code task to build the debug bundle - Enable Python debug wiring in the server and tests - Ensure a single stable Python debug session during startup
This commit is contained in:
+18
-3
@@ -38,6 +38,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
const serverInfo = loadServerDefaults()
|
||||
const serverName = serverInfo.name
|
||||
const serverId = serverInfo.module
|
||||
const pythonDebugMode = process.env.USE_DEBUGPY?.toLowerCase() === "true"
|
||||
|
||||
// Setup logging
|
||||
const outputChannel = createOutputChannel(serverName)
|
||||
@@ -101,10 +102,15 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
return runServerQueue
|
||||
}
|
||||
|
||||
if (!pythonDebugMode) {
|
||||
context.subscriptions.push(
|
||||
onDidChangePythonInterpreter(async () => {
|
||||
await runServer()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
context.subscriptions.push(
|
||||
onDidChangePythonInterpreter(async () => {
|
||||
await runServer()
|
||||
}),
|
||||
onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => {
|
||||
if (checkIfConfigurationChanged(e, serverId)) {
|
||||
await runServer()
|
||||
@@ -116,6 +122,15 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
)
|
||||
|
||||
setImmediate(async () => {
|
||||
if (pythonDebugMode) {
|
||||
// A debugpy listen session is attached to exactly one process. Do not
|
||||
// subscribe to interpreter changes during startup, as the Python
|
||||
// extension can emit a duplicate event and restart that process.
|
||||
traceLog("Python debug mode: starting one stable server session")
|
||||
await runServer()
|
||||
return
|
||||
}
|
||||
|
||||
const interpreter = getInterpreterFromSetting(serverId)
|
||||
if (interpreter === undefined || interpreter.length === 0) {
|
||||
traceLog(`Python extension loading`)
|
||||
|
||||
Reference in New Issue
Block a user