Skip to content
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

--reload is returning OSError: WinError 10038 when file saved #118

Closed
LizardLiang opened this issue Apr 15, 2023 · 6 comments · Fixed by #148
Closed

--reload is returning OSError: WinError 10038 when file saved #118

LizardLiang opened this issue Apr 15, 2023 · 6 comments · Fixed by #148

Comments

@LizardLiang
Copy link

I'm currently working on a project with Fastapi and Hypercorn on Windows 11

I'm having trouble adding "reload" flag to Hypercorn.

Every time I save my file, I get an OSError like below

image

After I installed Hypercorn version 0.13.2, the problem is no longer exists, everything works as expected

However the version of 0.14.3 does not.

This is the command I used to start the app: hypercorn -b 0.0.0.0:5000 -k asyncio -w 1 --reload main:app

Can you please tell me how to fix this?

thanks,

@GeorgeLPerkins
Copy link

I'm having this issue also.

@godjangollc
Copy link
Contributor

Is already fixed in pull request #148 , we must wait until they merge it into the main branch. I tested it on windows and issue is gone. You can test it and give me feedback in case I need to change anything. I hope it helps.

@iconberg
Copy link

iconberg commented Jan 4, 2024

I still have this WinError 10038 with 0.16.0 on Windows 10 and Python 3.9.7.
With 0.13.2 i can avoid this error.
hypercorn_error_10038.txt

@godjangollc
Copy link
Contributor

godjangollc commented Jan 4, 2024

I still have this WinError 10038 with 0.16.0 on Windows 10 and Python 3.9.7. With 0.13.2 i can avoid this error. hypercorn_error_10038.txt

version 0.15.0 should fix the main error, but @pgjones says it creates others issues... 0.16.0 reverted the pr where the error was tried to be fixed. I'm still saying, if @pgjones allows it, I will personally try to fix any error related to this issue. But worth nothing if it's rolled back as soon as there is any other error that I didn't see.

@joshft91
Copy link

I still have this WinError 10038 with 0.16.0 on Windows 10 and Python 3.9.7. With 0.13.2 i can avoid this error. hypercorn_error_10038.txt

version 0.15.0 should fix the main error, but @pgjones says it creates others issues... 0.16.0 reverted the pr where the error was tried to be fixed. I'm still saying, if @pgjones allows it, I will personally try to fix any error related to this issue. But worth nothing if it's rolled back as soon as there is any other error that I didn't see.

Just out of curiosity, where are we at with this issue? All issues seem to indicate the --reload problem is resolved, but I'm still getting the error described in this issue when using 0.16.0.

@ArchiDevil
Copy link

ArchiDevil commented Jun 20, 2024

Getting this error in 0.17.3. The full callstack is

PS C:\Users\ArchiDevil\Desktop\hat\backend> hypercorn --debug --reload asgi:app                                                                          
[2024-06-20 19:40:36 +0300] [9332] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)
Accept failed on a socket
handle_traceback: Handle created at (most recent call last):
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 607, in run_forever
    self._run_once()
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1914, in _run_once
    handle._run()
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 134, in worker_serve
    await asyncio.start_server(_server_callback, backlog=config.backlog, sock=sock)
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\streams.py", line 84, in start_server
    return await loop.create_server(factory, host, port, **kwds)
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1547, in create_server
    server._start_serving()
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 316, in _start_serving
    self._loop._start_serving(
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 878, in _start_serving
    self.call_soon(loop)
socket: <asyncio.TransportSocket fd=608, family=2, type=1, proto=6, laddr=('127.0.0.1', 8000)>
Traceback (most recent call last):
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 860, in loop
    f = self._proactor.accept(sock)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 583, in accept
    self._register_with_iocp(listener)
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 752, in _register_with_iocp
    _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] Параметр задан неверно
unhandled exception during asyncio.run() shutdown
task: <Task finished name='Task-2' coro=<Lifespan.handle_lifespan() done, defined at C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\lifespan.py:42> exception=LifespanFailureError('Lifespan failure in shutdown. \'Traceback (most recent call last):\n  File "C:\\Users\\ArchiDevil\\Desktop\\hat\\backend\\.venv\\Lib\\site-packages\\hypercorn\\asyncio\\run.py", line 234, in _run\n    runner.run(main(shutdown_trigger=shutdown_trigger))\n  File "C:\\Users\\ArchiDevil\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\\runners.py", line 118, in run\n    return self._loop.run_until_complete(task)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "C:\\Users\\ArchiDevil\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\\base_events.py", line 653, in run_until_complete\n    return future.result()\n           ^^^^^^^^^^^^^^^\n  File "C:\\Users\\ArchiDevil\\Desktop\\hat\\backend\\.venv\\Lib\\site-packages\\hypercorn\\asyncio\\run.py", line 136, in worker_serve\n    bind = repr_socket_addr(sock.family, sock.getsockname())\n                                         ^^^^^^^^^^^^^^^^^^\nOSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\Users\\ArchiDevil\\Desktop\\hat\\backend\\.venv\\Lib\\site-packages\\starlette\\routing.py", line 741, in lifespan\n    await receive()\n  File "C:\\Users\\ArchiDevil\\Desktop\\hat\\backend\\.venv\\Lib\\site-packages\\hypercorn\\asyncio\\lifespan.py", line 110, in asgi_receive\n    return await self.app_queue.get()\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "C:\\Users\\ArchiDevil\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\\queues.py", line 158, in get\n    await getter\nasyncio.exceptions.CancelledError\n\'') created at C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py:83>
Traceback (most recent call last):
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 234, in _run
    runner.run(main(shutdown_trigger=shutdown_trigger))
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 136, in worker_serve
    bind = repr_socket_addr(sock.family, sock.getsockname())
                                         ^^^^^^^^^^^^^^^^^^
OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\routing.py", line 741, in lifespan
    await receive()
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\lifespan.py", line 110, in asgi_receive
    return await self.app_queue.get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\queues.py", line 158, in get
    await getter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\lifespan.py", line 55, in handle_lifespan
    await self.app(
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\app_wrappers.py", line 34, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\middleware\errors.py", line 151, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\middleware\cors.py", line 77, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\middleware\exceptions.py", line 51, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\routing.py", line 765, in app
    await self.lifespan(scope, receive, send)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\routing.py", line 745, in lifespan
    await send({"type": "lifespan.shutdown.failed", "message": exc_text})
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\lifespan.py", line 122, in asgi_send
    raise LifespanFailureError("shutdown", message.get("message", ""))
hypercorn.utils.LifespanFailureError: Lifespan failure in shutdown. 'Traceback (most recent call last):
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 234, in _run
    runner.run(main(shutdown_trigger=shutdown_trigger))
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 136, in worker_serve
    bind = repr_socket_addr(sock.family, sock.getsockname())
                                         ^^^^^^^^^^^^^^^^^^
OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\starlette\routing.py", line 741, in lifespan
    await receive()
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\lifespan.py", line 110, in asgi_receive
    return await self.app_queue.get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\queues.py", line 158, in get
    await getter
asyncio.exceptions.CancelledError
'
Process SpawnProcess-2:
Traceback (most recent call last):
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
    self._target(*self._args, **self._kwargs)
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 196, in asyncio_worker
    _run(
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 234, in _run
    runner.run(main(shutdown_trigger=shutdown_trigger))
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ArchiDevil\Desktop\hat\backend\.venv\Lib\site-packages\hypercorn\asyncio\run.py", line 136, in worker_serve
    bind = repr_socket_addr(sock.family, sock.getsockname())
                                         ^^^^^^^^^^^^^^^^^^
OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants