--reload flag gives me an OSError on Windows
See original GitHub issueHi, I’m trying a basic example with uvicorn : https://github.com/Celeborn2BeAlive/python_uvicorn_example It’s working but no the reload function: when I modify a file I get an OSError and the server seems to block when I refresh my page in my browser. After that I have to kill the server and start it again. Here is my complete output from uvicorn:
$ uvicorn.exe example:app --reload
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [18104]
INFO: Started server process [8440]
INFO: Waiting for application startup.
INFO: ASGI 'lifespan' protocol appears unsupported.
INFO: Application startup complete.
INFO: 127.0.0.1:59375 - "GET / HTTP/1.1" 200
INFO: 127.0.0.1:59375 - "GET /favicon.ico HTTP/1.1" 200
WARNING: Detected file change in 'example.py'. Reloading...
INFO: Started server process [15148]
ERROR: Accept failed on a socket
socket: <asyncio.TransportSocket fd=812, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 8000)>
Traceback (most recent call last):
File "c:\python38\Lib\asyncio\proactor_events.py", line 817, in loop
f = self._proactor.accept(sock)
File "c:\python38\Lib\asyncio\windows_events.py", line 545, in accept
self._register_with_iocp(listener)
File "c:\python38\Lib\asyncio\windows_events.py", line 714, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] Paramètre incorrect
INFO: Waiting for application startup.
INFO: ASGI 'lifespan' protocol appears unsupported.
INFO: Application startup complete.
Here is some details about my system:
- python 3.8.0
- uvicorn 0.10.3 (installed from pip)
- Windows 10 Professional x64 1903 18362.418
Note that I also tried with python 3.7.x and uvicorn 0.9.x and I had the same results.
Thanks for your work on uvicorn 👍
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Developers - --reload flag gives me an OSError on Windows -
It's working but no the reload function: when I modify a file I get an OSError and the server seems to block when...
Read more >python 3.x - The --reload flag should not be used in production ...
WARNING: The --reload flag should not be used in production on Windows. Below is my code: from fastapi import FastAPI from fastapi.middleware.
Read more >System Error Codes (0-499) (WinError.h) - Win32 apps
To retrieve the description text for the error in your application, use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag.
Read more >System Error Codes (1000-1299) (WinError.h) - Win32 apps
To retrieve the description text for the error in your application, use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag.
Read more >Errors when applications try to connect to SQL Server in ...
Applications experience forcibly closed TLS connection errors when connecting SQL Servers in Windows · Symptoms · Cause · Resolution · Workaround.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hrm. That’s interesting. Could you open a fresh issue to track this, so we’ve got a cleaner history on the issue (there’s a few bits and pieces mashed together on this one.)
I think we probably want to default to
asyncio
on all platforms at the moment, since the IOCP variant seems more flaky.You’d be welcome to make a PR onto it as well if you fancy…
https://github.com/encode/uvicorn/blob/ad4ea90568a42eaa24cc6c597783246de5f35915/uvicorn/loops/auto.py#L8
This is where we’re auto-selecting which event loop to use. We probably just want to get rid of the
if sys.platform == "win32":
branch entirely.Thanks for bringing this up!