with 'uvicorn==0.21.0' modifications made to the 'request.state' persist between requests #1901
-
support of the Code snippet: from starlette.applications import Starlette
from starlette.responses import PlainTextResponse
from starlette.routing import Route
def handler(request):
if not hasattr(request.state, "foo"):
request.state.foo = 10
else:
request.state.foo += 1
return PlainTextResponse(f"Foo: {request.state.foo}")
app = Starlette(debug=True, routes=[Route('/', handler),]) Demonstration: simplescreenrecorder-.3.mp4Installed packages and python version:
|
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 1 reply
-
It's a bug on uvicorn, not on Starlette. It looks like the state is persisting per connection, not per request. cc @adriangb (I can fix it later, just letting you know) |
Beta Was this translation helpful? Give feedback.
It's a bug on uvicorn, not on Starlette.
It looks like the state is persisting per connection, not per request.
cc @adriangb (I can fix it later, just letting you know)