Run hypercorn with multiple workers on Windows - WinError 10022
See original GitHub issueDescribe the bug Hypercorn doesn’t seem to be able to start with multiple workers on Windows. Seems like the socket is not ready to bind and Windows, therefore, throws an exception. This may be different on Unix systems.
Code snippet Starlette Hello World
main.py
from starlette.applications import Starlette
from starlette.responses import JSONResponse
app = Starlette(debug=True)
@app.route('/')
async def homepage(request):
return JSONResponse({'hello': 'world'})
Expected behavior Hypercorn starts and is ready to serve with multiple workers.
Environment
- Windows 10
- Hypercorn: 0.5.3
- Python 3.6.6 (same issue with Python 3.7.2)
- pipenv
- Starlette 0.11.4
Additional context
Command:
pipenv run hypercorn main:app -w 2
Exception:
Running on 127.0.0.1:8000 over http (CTRL + C to quit)
Process Process-2:
Traceback (most recent call last):
File "Python36_64\Lib\multiprocessing\process.py", line 258, in _bootstrap
self.run()
File "Python36_64\Lib\multiprocessing\process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File ".virtualenvs\starlettehelloworld-wohnvuzv\lib\site-packages\hypercorn\asyncio\run.py", line 214, in asyncio_worker
debug=config.debug,
File ".virtualenvs\starlettehelloworld-wohnvuzv\lib\site-packages\hypercorn\asyncio\run.py", line 244, in _run
loop.run_until_complete(main)
File "Python36_64\Lib\asyncio\base_events.py", line 468, in run_until_complete
return future.result()
File ".virtualenvs\starlettehelloworld-wohnvuzv\lib\site-packages\hypercorn\asyncio\run.py", line 178, in worker_serve
for sock in sockets
File ".virtualenvs\starlettehelloworld-wohnvuzv\lib\site-packages\hypercorn\asyncio\run.py", line 178, in <listcomp>
for sock in sockets
File "Python36_64\Lib\asyncio\base_events.py", line 1065, in create_server
sock.listen(backlog)
OSError: [WinError 10022] An invalid argument was supplied
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
tiangolo/fastapi - Gitter
Hi guys, Im getting this error when im running the FastAPI app with uvicorn workers 2 ... OSError: [WinError 10022] An invalid argument...
Read more >OSError: [WinError 10022] An invalid argument was supplied ...
I am running this server code on Visual Studio Code for a server project: import socket from _thread import * import sys server ......
Read more >CHANGELOG.rst · a48f393605fcab4a7de46a793e9ef5260731152e ...
Bugfix WinError 10022 Invalid argument to allow multiple workers on Windows. Bugfix handle logger targets equal to None. Bugfix don't send empty bytes...
Read more >Hypercorn is now a Trio ASGI Server | by Philip Jones - Medium
Given that Hypercorn can run with either an asyncio, uvloop, or trio worker class it seems natural to compare the performance of each....
Read more >Invalid Http Method In Traceback: Uvicorn - ADocLib
... Im getting this error when im running the FastAPI app with uvicorn workers 2 OSError: [WinError 10022] An invalid argument was supplied....
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 Free
Top 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
Ah, looks like #4. I’m at a loss with this bug, as I don’t understand how windows works in this regard. I’ll try investigating though.
I think I’ve fixed this in 146e09556ec74eac2a37f31f831a00d3b2e7b780 in master, could you try it and confirm?