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

Fix aiohttp_asgi with aiohttp>=3.10.6... #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meyerj
Copy link

@meyerj meyerj commented Nov 6, 2024

... with aio-libs/aiohttp#9200, and forward websocket subprotocols from the request headers.

I probably shouldn't have mixed these two things, but this version works for me with

aiohttp==3.10.9
channels==4.1.0
Django==4.2.16

to run a Django application with Channels and web sockets as an ASGIResource from an aiohttp application.

Without this patch the following exception is raised:

[server-1] Traceback (most recent call last):
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 477, in _handle_request
[server-1]     resp = await request_handler(request)
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_app.py", line 559, in _handle
[server-1]     return await handler(request)
[server-1]   File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_middlewares.py", line 114, in impl
[server-1]     prev = match_info.current_app
[server-1] AttributeError: 'ASGIMatchInfo' object has no attribute 'current_app'

From aiohttp/CHANGES.rst:

Improved middleware performance -- by :user:bdraco.

The set_current_app method was removed from UrlMappingMatchInfo because it is no longer used, and it was unlikely external caller would ever use it.

Related issues and pull requests on GitHub: :issue:9200.

Likely the changes are not backwards compatible to older versions of aiohttp as-is...

Related to #2.

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 this pull request may close these issues.

1 participant