Skip to content

Commit

Permalink
Add the geventCompatible launch configuration option (DonJayamanne#…
Browse files Browse the repository at this point in the history
…1699)

* Fix tslint errors brought in by typescript@2.8.3

* Add the `geventCompatible` launch configuration option

This makes the experimental Python debugger work with projects using
gevent's monkey patching.

Closes microsoft#127
  • Loading branch information
underyx authored and Aman Agarwal committed Aug 30, 2018
1 parent b4cc455 commit fa94859
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/1 Enhancements/127.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `gevent` launch configuration option to enable debugging of gevent monkey patched code.
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,17 @@
"jinja": true
}
},
{
"label": "Python Experimental: Gevent",
"description": "%python.snippet.launch.gevent.description%",
"body": {
"name": "Gevent",
"type": "pythonExperimental",
"request": "launch",
"program": "^\"\\${file}\"",
"gevent": true
}
},
{
"label": "Python Experimental: PySpark",
"description": "%python.snippet.launch.pyspark.description%",
Expand Down Expand Up @@ -975,6 +986,11 @@
"description": "Debug standard library code.",
"default": false
},
"gevent": {
"type": "boolean",
"description": "Enable debugging of gevent monkey-patched code.",
"default": false
},
"django": {
"type": "boolean",
"description": "Django debugging.",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"python.snippet.launch.flask.description": "Debug a Flask Application",
"python.snippet.launch.flaskOld.label": "Python: Flask (0.10.x or earlier)",
"python.snippet.launch.flaskOld.description": "Debug an older styled Flask Application",
"python.snippet.launch.gevent.label": "Python: Gevent",
"python.snippet.launch.gevent.description": "Debug a Gevent Application",
"python.snippet.launch.pyramid.label": "Python: Pyramid Application",
"python.snippet.launch.pyramid.description": "Debug a Pyramid Application",
"python.snippet.launch.watson.label": "Python: Watson Application",
Expand Down
2 changes: 2 additions & 0 deletions src/client/debugger/Common/Contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type DebuggerType = 'python' | 'pythonExperimental';
export interface AdditionalLaunchDebugOptions {
redirectOutput?: boolean;
django?: boolean;
gevent?: boolean;
jinja?: boolean;
debugStdLib?: boolean;
sudo?: boolean;
Expand All @@ -70,6 +71,7 @@ export interface AdditionalLaunchDebugOptions {
export interface AdditionalAttachDebugOptions {
redirectOutput?: boolean;
django?: boolean;
gevent?: boolean;
jinja?: boolean;
debugStdLib?: boolean;
}
Expand Down
7 changes: 6 additions & 1 deletion src/client/debugger/DebugClients/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DebugClientHelper {

// Merge variables from both .env file and env json variables.
const envFileVars = await this.envParser.parseFile(args.envFile);
const debugLaunchEnvVars = (args.env && Object.keys(args.env).length > 0) ? { ...args.env } as EnvironmentVariables : {};
// tslint:disable-next-line:no-any
const debugLaunchEnvVars: {[key: string]: string} = (args.env && Object.keys(args.env).length > 0) ? { ...args.env } as any : {} as any;
const env = envFileVars ? { ...envFileVars! } : {};
this.envParser.mergeVariables(debugLaunchEnvVars, env);

Expand Down Expand Up @@ -51,6 +52,10 @@ export class DebugClientHelper {
env.PYTHONUNBUFFERED = '1';
}

if (args.gevent) {
env.GEVENT_SUPPORT = 'True'; // this is read in pydevd_constants.py
}

return env;
}
}

0 comments on commit fa94859

Please sign in to comment.