You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Endpoint is function or method. Treat it as `func(websocket)`.
self.app=websocket_session(endpoint)
else:
# Endpoint is a class. Treat it as ASGI.
self.app=endpoint
).
Debugging material
Traceback (most recent call last):
File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 199, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 146, in __call__
await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/exceptions.py", line 58, in __call__
await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 315, in handle
await self.app(scope, receive, send)
TypeError: handle_ws() takes 1 positional argument but 3 were given
Environment
OS: Arch Linux
Python version: 3.9.9
Starlette version: 0.17.1
Additional context
Support for functools.partial for Route was introduced in #984.
Those changes to Route.__init__ fix this bug too but just copying them feels unsustainable.
The text was updated successfully, but these errors were encountered:
Checklist
master
.Describe the bug
Accessing a WebSocketRoute with async function wrapped in functools.partial raises TypeError.
To reproduce
Install
uvicorn[standard]
, run withuvicorn bug:app
.Access
ws://localhost:8000
with e.g. wscat.Expected behavior
WebSocketRoute should work with functools.partial just like Route.
Actual behavior
The route fails because it is treated as an ASGI application (ref.
starlette/starlette/routing.py
Lines 279 to 284 in f53faba
Debugging material
Environment
Additional context
Support for functools.partial for Route was introduced in #984.
Those changes to
Route.__init__
fix this bug too but just copying them feels unsustainable.The text was updated successfully, but these errors were encountered: