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.

[BUG] WinError 10022 when run on Windows with workers > 1

See original GitHub issue

The error observed on Windows 10 with Python-3.6-amd64, Python-3.7-amd64, Python-3.8-amd64. Sample app:

async def app(scope, receive, send):
    assert scope['type'] == 'http'
    await send({
        'type': 'http.response.start',
        'status': 200,
        'headers': [
            [b'content-type', b'text/plain'],
        ]
    })
    await send({
        'type': 'http.response.body',
        'body': b'Uvicorn is the best!',
    })

OK when workers=1:

(venv) C:\Users\vasiliy.pankov\Projects\uvicorn-lab>uvicorn server:app
INFO:     Started server process [17728]
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO:     Shutting down
INFO:     Finished server process [17728]

WinError 10022 When workers > 1

(venv) C:\Users\vasiliy.pankov\Projects\uvicorn-lab>uvicorn --workers 2 server:app
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started parent process [13020]
INFO:     Started server process [6888]
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO:     Started server process [19460]
Process SpawnProcess-1:
Traceback (most recent call last):
  File "C:\Python\Python38\lib\multiprocessing\process.py", line 313, in _bootstrap
    self.run()
  File "C:\Python\Python38\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "c:\users\vasiliy.pankov\projects\uvicorn-lab\venv\lib\site-packages\uvicorn\subprocess.py", line 73, in subprocess_started
    target(sockets=sockets)
  File "c:\users\vasiliy.pankov\projects\uvicorn-lab\venv\lib\site-packages\uvicorn\main.py", line 341, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "C:\Python\Python38\lib\asyncio\base_events.py", line 608, in run_until_complete
    return future.result()
  File "c:\users\vasiliy.pankov\projects\uvicorn-lab\venv\lib\site-packages\uvicorn\main.py", line 358, in serve
    await self.startup(sockets=sockets)
  File "c:\users\vasiliy.pankov\projects\uvicorn-lab\venv\lib\site-packages\uvicorn\main.py", line 386, in startup
    server = await loop.create_server(
  File "C:\Python\Python38\lib\asyncio\base_events.py", line 1469, in create_server
    server._start_serving()
  File "C:\Python\Python38\lib\asyncio\base_events.py", line 309, in _start_serving
    sock.listen(self._backlog)
OSError: [WinError 10022] An invalid argument was supplied

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
daddycocoamancommented, Jul 7, 2020

+1 to fix from @euri10. Would be great to see this implemented.

0reactions
janhurstcommented, Jul 13, 2020

Also running into this issue on Win10 dev machine and Windows Server 2016 LTS docker container target.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python OSError: [WinError 10022] An invalid argument was ...
You are invoking accept method on client socket which is not set to passive mode by calling listen . Moreover, the socket is...
Read more >
Trying to send self-created SYN packet and I face error ...
Hi, I'm learning about RAW packet creation in python. This is code from inc0x0.com that I have been working on. s = socket.socket(socket....
Read more >
tiangolo/fastapi - Gitter
Hi guys, Im getting this error when im running the FastAPI app with uvicorn workers 2. Traceback (most recent call last):
Read more >
OSError: [WinError 10022] An invalid argument was supplied
I am currently learning python, coming from java, and stumbled into an error I can't find the answer to. I am using the...
Read more >
OSError: [WinError 10022] An invalid ... - Google Groups
The strangest thing is, that I got it to work when upgrading from 0.11 to 0.12, then I left my PC to get...
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