question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run hypercorn with multiple workers on Windows - WinError 10022

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pgjonescommented, Apr 4, 2019

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.

1reaction
pgjonescommented, Aug 15, 2019

I think I’ve fixed this in 146e09556ec74eac2a37f31f831a00d3b2e7b780 in master, could you try it and confirm?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found