I have created a Flask app and start to build my project, but when I use breakpoint in any file for debugging, vscode will automatically stop at this line HTTPServer.serve_forever(self)
in flask default module.
Thing is annoying since it will jump to this line and ignore my original breakpoint, make me hard to debug.
Any idea?
launch.json
{
"name": "Python: Custom Flask",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/venv/bin/activate",
"module": "flask",
"env": {
"ENV": ".local"
},
"args": [
"run",
]
}
serving.py
def serve_forever(self):
self.shutdown_signal = False
try:
HTTPServer.serve_forever(self) # <- Always stop on this line
except KeyboardInterrupt:
pass
finally:
self.server_close()
app.py
from flask import app
app = Flask(__name__)
@app.route('/')
def index():
return "OK"
app.run()
This issue is being tracked here: https://github.com/Microsoft/vscode-python/issues/2498
Looks like the issue is fixed in the development branch of the Python plugin and a workaround for now is
you can continue debugging by selecting your thread in the "Call Stack" window. source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With