Running flask in VSCode cause HTTPServer.serve_forever(self) breakpoint everytime

Viewed 373

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()
1 Answers
Related