-
-
Notifications
You must be signed in to change notification settings - Fork 754
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 occurs when workers > 1 #1317
Comments
I have this problem as well - Presumably it works with I see a log message: Windows 10 Pro This does not happen with Uvicorn 0.15.0 |
can confirm I boote a win box, the app seems functional though just with this error message |
maybe the issue is that in the multiprocess case we dont call Server.startup but Server.serve directly, and iirc in startup method we have something to share sockets on windows so maybe we got the flow wrong here ? |
This seemed to fix this issue for me Pull Request #1443 |
Checklist
master
.Describe the bug
This bug outputs an error similar to #529 but occurs on different parameters of uvicorn. It occurs when I run uvicorn with the following settings:
uvicorn.run("main:app", host="0.0.0.0", port=8000, workers=2, reload=False, loop="asyncio")
I received the following exceptions:
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started parent process [16448]
INFO: Started server process [17848]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Started server process [8104]
INFO: Waiting for application startup.
INFO: Application startup complete.
Accept failed on a socket
socket: <asyncio.TransportSocket fd=3552, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8000)>
Traceback (most recent call last):
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 834, in loop
f = self._proactor.accept(sock)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 549, in accept
self._register_with_iocp(listener)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 718, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] The parameter is incorrect
Note that the app is still working completely fine. Setting either
workers=1
orreload=True
makes the exceptions go away, while the app still works perfectly fine. Settingworkers=n
to any numbern>1
makes the exception appearn-1
times. For example, withuvicorn.run("main:app", host="0.0.0.0", port=8000, workers=4, reload=False, loop="asyncio")
:INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started parent process [14188]
INFO: Started server process [18744]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Started server process [25288]
INFO: Waiting for application startup.
INFO: Application startup complete.
Accept failed on a socket
socket: <asyncio.TransportSocket fd=880, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8000)>
Traceback (most recent call last):
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 834, in loop
f = self._proactor.accept(sock)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 549, in accept
self._register_with_iocp(listener)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 718, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] The parameter is incorrect
INFO: Started server process [25760]
INFO: Waiting for application startup.
INFO: Application startup complete.
Accept failed on a socket
socket: <asyncio.TransportSocket fd=1772, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8000)>
Traceback (most recent call last):
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 834, in loop
f = self._proactor.accept(sock)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 549, in accept
self._register_with_iocp(listener)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 718, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] The parameter is incorrect
INFO: Started server process [21280]
INFO: Waiting for application startup.
INFO: Application startup complete.
Accept failed on a socket
socket: <asyncio.TransportSocket fd=3872, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8000)>
Traceback (most recent call last):
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 834, in loop
f = self._proactor.accept(sock)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 549, in accept
self._register_with_iocp(listener)
File "C:\Users\phanm\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 718, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] The parameter is incorrect
Steps to reproduce the bug
No response
Expected behavior
No response
Actual behavior
No response
Debugging material
No response
Environment
Additional context
The exceptions do not occur with the following settings:
uvicorn.run("main:app", host="0.0.0.0", port=8000, workers=2, reload=True, loop="asyncio")
uvicorn.run("main:app", host="0.0.0.0", port=8000, workers=1, reload=False, loop="asyncio")
uvicorn.run("main:app", host="0.0.0.0", port=8000, workers=1, reload=True, loop="asyncio")
The text was updated successfully, but these errors were encountered: