-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSError on reload when running Werkzeug server with vs code debugger #1679
Comments
Hi @sergehauri can you try again with the latest version of the Python extension? I tried to replicate the error, but in my case it works fine. Could you confirm that the error persist? Thanks |
Hi @paulacamargo25 Python version: 3.11.3
There's some additional Debugger warning messages in the output, though I don't think they're of relevance.
|
I am experiencing the same issue with my Flask application in VS Code. I am running the same versions as @sergehauri in my app, but to uncomplicate things, I created a new project and followed their reproduction instructions and receive the same traceback when debugging following a reload.
|
Thanks @sergehauri, I will try to reproduce the bug. |
facing the same issue, Python3.11.0 and 3.11.4, Flask-2.2.5 and Flask-2.3.2 |
Related Werkzeug issue ticket: pallets/werkzeug#2627 Related on Stack Overflow: |
May I ask if there are any updates on this issue, I have the same problem with Flask 2.3.3, werkzeug 2.3.7, Python 3.11.4 |
Just wanted to add that this is happening to me as well: Flask 3.0.0, Werkzeug 3.0.1, VS Code 1.83.1, and Python extensions 2023.20.0. Same behavior on Python 3.10.6, 3.11.4, and 3.12.0. Running "flask run --debug" from the command line doesn't have this issue - I can change and save files and it detects the change and restarts with no issue, so it's only while debugging inside VS Code. |
Hi, Same here. Thank you |
My python setup and module list are: ` VSCODE: Python extension pack: v1.7.0 |
After a bit of digging, I think the real issue here is that VS Code Python debugger considers a System.Exit with any code other than zero to be an exception and there's no way (currently) to change this functionality (other than ignoring all exceptions, which isn't ideal). When it's running without a debugger, the child process executes the System.Exit(3) and it's caught by the outer process and triggers a restart of the server, all before the other exception (the socket issue) is exposed - but when the debugger is attached (either launched from inside VS Code or launched separately and then attached from VS Code), it stops on the Exit and also allows the other exception to be exposed instead of swallowed. I messed around a bit and can't get code that both swallows this exception and allows the server to restart on file changes as expected. StackOverflow Post (with people checking in every year since 2018 with "Still not fixed"): https://stackoverflow.com/questions/52372810/visual-studio-code-python-debugging-exception-has-occurred-systemexit Open DebugPy issue: #1306 |
2024, I have the latest of everything from VSCode to Python 3.11 to Flask 3 and even Werkzeug 3.0.2 yet I have the exact issue. Did all suggestions for Winsock2 fixes and nothing changed.
|
@rwmnau @sergehauri @nimicohgr @olidel001 The behavior of debugpy is not in compliance with the specifications. Because the underlying issue is broader, I raised a separate ticket on the matter, which explains the problem and suggests a solution that should not only fix the issue you are having, but other issues as well. Unforatunately, it was closed and moved to a discussion. Please contribute, if you wish to see it fixed. |
Type: Bug
Behaviour
Expected vs. Actual
The Werkzeug development server features a reloader, which checks the files of the wsgi application it's running and restarts the server if there are any changes. In Werkzeug 2.2.3, they fixed an issue with unclosed sockets the development server (issue: pallets/werkzeug#2421, fix: pallets/werkzeug#2517).
With that fix, running the werkzeug server with the vs code debugger causes the following exception when reloading the app:
The specific change causing this behaviour is the finally block in src/werkzeug/serving.py on lines 1066-1067.
Steps to reproduce:
"Start Debugging"
vs code runs the following command:
(venv) PS C:\Users\TAAHASE0\dev\projects\werkzeugtest> c:; cd 'c:\Users\TAAHASE0\dev\projects\werkzeugtest'; & 'c:\Users\TAAHASE0\dev\projects\werkzeugtest\venv\Scripts\python.exe' 'c:\Users\TAAHASE0\.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '50758' '--' '-m' 'flask' 'run' '--no-debugger'
Save the app.py file, which causes the werkzeug dev server to reload
* Detected change in 'C:\\Users\\TAAHASE0\\dev\\projects\\werkzeugtest\\app.py', reloading
which leads to the before mentioned Exception.
Running the flask app directly from the terminal does not cause this behavior, it reloads the app without error, so it's not an issue of the werkzeug server itself:
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2023.6.0
VS Code version: Code 1.77.0 (7f329fe6c66b0f86ae1574c2911b681ad5a45d63, 2023-03-29T10:02:16.981Z)
OS version: Windows_NT x64 10.0.19042
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: