The new Python debugger in version 2022 won't stop with Flask routes
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
- build a flask project with blueprint for routing
- add the following status test route
@api.route('/', methods=['GET'])
def index():
print(" in index ")
return '
welcome to my API
', 200 - set a breakpoint on line 'print("in index")'
- 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
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.
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.
Pavel, assigning this to you if you don't mind :)
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
Seems it has been fixed with latest 17.1.6, I tried and it works with or without debug=False option. Great!
nope - have 17.1.6 as well, but with debug=True i was not able to set a bp in a callback ... strange
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.
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.
setting app debug to False worked for me