Debian Codegraph @

docs/examples/application_state/using_immutable_state.py

raw
1 from typing import Any, Dict
2
3 from litestar import Litestar, get
4 from litestar.datastructures import ImmutableState
5
6
7 @get("/", sync_to_thread=False)
8 def handler(state: ImmutableState) -> Dict[str, Any]:
9 setattr(state, "count", 1) # raises AttributeError
10 return state.dict()
11
12
13 app = Litestar(route_handlers=[handler])