Debug Reloader and the Debugger in VS Code: SystemExit: 3

Hello Community,
am trying to develop a Dash/Plotly app in Python using Visual Studio Code but am running into SystemExit: 3 on reloading.

Have the most basic example from a tutorial:

import dash
from dash import html

app = dash.Dash(__name__)
app.layout = html.H1(children="Welcome to Dash!")

if __name__ == "__main__":
    app.run_server(debug=True)

This works find when I start it from the command line (including the reload mechanism). However if I start it through VSC with a configured launch file, then the reload feature breaks.
Whenever I edit the file and save, it throws:

Exception has occurred: SystemExit
3
  File "C:\MYPATH_STUFF\PlotlyExperiments\main.py", line 9, in <module>
    app.run_server(debug=True)

The config I use is:

            "name": "PY Plotly Experiment",
            "type": "python",
            "request": "launch",
            "python": "C:/Users/MY_USER/.conda/envs/PY_37/python.exe",
            "program": "${workspaceFolder}/main.py",
            "console": "integratedTerminal",
            "args": []

Anybody knows what SystemExit errorcode 3 refers to?
Or have you encountered this problem?
Is it not possible to have debugging as well as the reload feature?

Huge thanks in advance!

I am seeing the same error.

I’m using:

  • VS Code on Windows
  • Plotly 5.6.0
  • Flask 2.1.1

Any ideas?

Use app.run_server(debug=False). I don’t know the mechanics, but looks like flask’s debug mode is not compatible with vscode’s debugger.

@charris @AlexG

The SystemExit errorcode 3 is an exception thrown by werkzeug to trigger the reloader. As it is an uncaught exception, the debugger will break at this point (unless you uncheck “Uncaught Exceptions”, which defeats the purpose of debugging). In other words, if you continue the debugger after this break, the application will reload.

To avoid having to do an extra step every time, you can pass "flask": true in the config, so this breakpoint is skipped. Please note that the reloading can be significantly slower in the debugger.

1 Like

You can uncheck the “Uncaught Exceptions” in the left bottom “BREAKPOINTS” panel. Then the problem is resolved.