Flask is not running when Debug is True on Windows
Ambitiont109 opened this issue · 1 comments
from flask import Flask
app = Flask(__name__)
if __name__ == "__main__":
app.run(debug=True)
I made main.py like above.
and tried to run it with below command
flask run --app test --debug
python main.py
both way got the error like below
Traceback (most recent call last): File "D:\Employer\Security Snares\ransomsnare-backend\flask\test.py", line 4, in <module> app.run(debug=True) File "D:\Employer\Security Snares\vee\lib\site-packages\flask\app.py", line 615, in run run_simple(t.cast(str, host), port, self, **options) File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 1077, in run_simple srv = make_server( File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 917, in make_server return ThreadedWSGIServer( File "D:\Employer\Security Snares\vee\lib\site-packages\werkzeug\serving.py", line 779, in __init__ self.socket = socket.fromfd(fd, address_family, socket.SOCK_STREAM) File "C:\Users\K_Teacher\AppData\Local\Programs\Python\Python310\lib\socket.py", line 545, in fromfd nfd = dup(fd) OSError: [WinError 10038] An operation was attempted on something that is not a socket
Environment:
- Python version: 3.10
- Flask version: 2.3.2, 3.0.2
- OS: Windows 10
As with previous reported incidences of this, I cannot reproduce this issue with the information provided. The dev server reloader tests pass on Windows in CI. When I run a project locally it works as expected as well. It is impossible for me to identify the issue or evaluate a proposed fix if I don't have a reproducing example to test against.
> mkdir example
> cd example
> py -3.12 -m venv .venv
> .venv\Scripts\activate
> pip install flask
# example.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello, World!"
> flask -A example run --debug
* Serving Flask app 'example'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Runnning on http://127.0.0.1:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 123-456-789
127.0.0.1 - - [06/Mar/2024 11:44:09] "GET / HTTP/1.1" 200 -
* Detected change in 'C:\\Users\\David\\Projects\\example\\example.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 123-456-789