PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

The new Python debugger in version 2022 won't stop with Flask routes

Open gzt036 opened this issue 4 years ago • 9 comments

Describe the bug the legacy debugger is not available in version 2022 anymore, however, the new debugger has serious bugs, it won't stop at flask routing functions, makes debugging flask apps almost impossible a task. Is it possible to enable legacy debugger in v 2022 if the new debugger just won't work.

Steps to Reproduce

  1. build a flask project with blueprint for routing
  2. add the following status test route @api.route('/', methods=['GET']) def index(): print(" in index ") return '

    welcome to my API

    ', 200
  3. set a breakpoint on line 'print("in index")'
  4. on your browser, type http://localhost:5000, 5000 is the port flask uses, yours could be different

Expected behavior normal behavior should trigger the breakpoint, however, in vs version 2022 it returns the message without trigger the breakpoint

Additional context and screenshots [Add any other information such as screenshots, error message, or stack trace]

Sample Code

XXX

Configuration information (If you are providing a diagnostics file (see below), skip this section) VS Version: [Can be found under "Help->About Microsoft Visual Studio"] PTVS version: [Can be found under "Help->About Microsoft Visual Studio->Installed products"] Python version: Debugger Type (if applicable): [New debugger or legacy debugger?]

Diagnostics file The diagnostics file contains information such as the Python version, environments, loaded assemblies, configuration options, etc. This file makes it easier for us to reproduce and fix bugs, so we would really appreciate it if you could provide it to us. This file can be generated by going to Tools->Options->Python->Diagnostics. You can attach the file to this issue or email it to us at [email protected]. If you email it, please add a link to this issue.

XXX

gzt036 avatar Dec 13 '21 09:12 gzt036

Are you using the Flask auto-reload feature, by chance? Due to the way it's implemented (multiple processes), VS doesn't handle it well.

int19h avatar Dec 13 '21 21:12 int19h

I removed (debug=true) from the server startup line app.run(HOST, PORT) , and it doesn't help. What I can confirm is that the legacy debugger in previous versions works, and there is no option to turn legacy debugger on in v2022.

gzt036 avatar Dec 14 '21 00:12 gzt036

Pavel, assigning this to you if you don't mind :)

AdamYoblick avatar Jan 05 '22 23:01 AdamYoblick

Are you using the Flask auto-reload feature, by chance? Due to the way it's implemented (multiple processes), VS doesn't handle it well.

Experimenting with Dash-Apps in VS2022 lead me to this topic: breakpoints in callback-methods were not hit, while 'normal'-breakpoints (e.g. in main) worked. Setting "app.run_server(debug=False)" solved it for me - callbacks-bp work now! Thx

clane2812 avatar Apr 28 '22 09:04 clane2812

Seems it has been fixed with latest 17.1.6, I tried and it works with or without debug=False option. Great!

gzt036 avatar Apr 28 '22 10:04 gzt036

nope - have 17.1.6 as well, but with debug=True i was not able to set a bp in a callback ... strange

clane2812 avatar Apr 28 '22 10:04 clane2812

You are right, Clane. What I mean is without specifying 'debug' option it works as well. That (debug=False) was not the default behavior previously, see my previous post. As mentioned by int19h, flask auto-reload does not work well with PTVS, so debug=true still won't work, you just have to restart the server after modification.

gzt036 avatar Apr 28 '22 10:04 gzt036

What's described above is the expected behavior currently.

For auto-reload support, we have an old issue to add subprocess debugging which is not specific to Flask - #125 - so I'm going to resolve this as a dupe of that.

int19h avatar Jun 13 '22 17:06 int19h

setting app debug to False worked for me

VincentAZ avatar Mar 12 '23 00:03 VincentAZ