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

aiohttp / sniffio is unhappy with "--opt" #447

Closed
MrHamel opened this issue Nov 30, 2024 · 1 comment · Fixed by #452
Closed

aiohttp / sniffio is unhappy with "--opt" #447

MrHamel opened this issue Nov 30, 2024 · 1 comment · Fixed by #452
Labels
wontfix This will not be worked on

Comments

@MrHamel
Copy link

MrHamel commented Nov 30, 2024

When I use granian with --opt, aiohttp's use of sniffio gets unhappy when trying to detect the async library, without --opt it works just fine. How I trigger this is by going to /docs in my FastAPI project, which produces an HTTP 500 - Internal Server Error with the below traceback.

  • Linux amd64
  • Python 3.13 with the project managed by uv + pyenv
[ERROR] Application callable raised an exception
Traceback (most recent call last):
  File "./discord_bot/.venv/lib/python3.13/site-packages/granian/asgi.py", line 118, in _http_logger
    rv = await _runner(scope, proto)
  File "./discord_bot/.venv/lib/python3.13/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "./discord_bot/.venv/lib/python3.13/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "./discord_bot/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 177, in __call__
    response = await self.handler(request, exc)
  File "./discord_bot/main.py", line 148, in catch_all_handler
    await async_excepthook(*sys.exc_info())
  File "./discord_bot/main.py", line 56, in async_excepthook
    ryan: discord.User = await discord_client.fetch_user(
  File "./discord_bot/.venv/lib/python3.13/site-packages/discord/client.py", line 1804, in fetch_user
    data = await self.http.get_user(user_id)
  File "./discord_bot/.venv/lib/python3.13/site-packages/discord/http.py", line 286, in request
    async with self.__session.request(
  File "./discord_bot/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 1359, in __aenter__
    self._resp: _RetType = await self._coro
  File "./discord_bot/.venv/lib/python3.13/site-packages/aiohttp/client.py", line 579, in _request
    with timer:
  File "./discord_bot/.venv/lib/python3.13/site-packages/aiohttp/helpers.py", line 712, in __enter__
    raise RuntimeError(
RuntimeError: Timeout context manager should be used inside a task
2024-11-30 09:39:34,432 - async_excepthook - ERROR: Exception in AsyncLibraryNotFoundError: unknown async library, or not in async context
@gi0baro
Copy link
Member

gi0baro commented Dec 1, 2024

Yeah, this falls into the same category of #387 and #323.
There's no plan to fix this: in fact I'm planning to just remove the --opt option at all given the actual performance gain in latest Python versions is somewhat unclear.

Gonna keep this opened until the option is removed.

@gi0baro gi0baro added the wontfix This will not be worked on label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants