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

DispatcherMiddleware causes CancelledError on shudown #258

Open
npt opened this issue Sep 26, 2024 · 0 comments
Open

DispatcherMiddleware causes CancelledError on shudown #258

npt opened this issue Sep 26, 2024 · 0 comments

Comments

@npt
Copy link

npt commented Sep 26, 2024

Copied from this comment on a different issue with DispatcherMiddleware:

When I use Hypercorn's serve to serve Hypercorn's DispatcherMiddleware, when the server exits, it raises a CancelledError with a traceback looking like:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File ".../__main__.py", line 69, in <module>
    asyncio.run(serve(dispatcher, config))
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.12/site-packages/hypercorn/asyncio/__init__.py", line 44, in serve
    await worker_serve(
  File ".../.venv/lib/python3.12/site-packages/hypercorn/asyncio/run.py", line 181, in worker_serve
    await lifespan_task
  File ".../.venv/lib/python3.12/site-packages/hypercorn/asyncio/lifespan.py", line 55, in handle_lifespan
    await self.app(
  File ".../.venv/lib/python3.12/site-packages/hypercorn/app_wrappers.py", line 34, in __call__
    await self.app(scope, receive, send)
  File ".../src/connector/__main__.py", line 57, in __call__
    await self.app(scope, receive, send)
  File ".../.venv/lib/python3.12/site-packages/hypercorn/middleware/dispatcher.py", line 19, in __call__
    await self._handle_lifespan(scope, receive, send)
  File ".../.venv/lib/python3.12/site-packages/hypercorn/middleware/dispatcher.py", line 46, in _handle_lifespan
    async with TaskGroup(asyncio.get_event_loop()) as task_group:
  File ".../.venv/lib/python3.12/site-packages/hypercorn/asyncio/task_group.py", line 74, in __aexit__
    await self._task_group.__aexit__(exc_type, exc_value, tb)
  File "/usr/lib/python3.12/asyncio/taskgroups.py", line 136, in __aexit__
    raise propagate_cancellation_error
  File "/usr/lib/python3.12/asyncio/taskgroups.py", line 112, in __aexit__
    await self._on_completed_fut
asyncio.exceptions.CancelledError
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

No branches or pull requests

1 participant