Skip to content

Commit 5377386

Browse files
committed
No need to use state
Signed-off-by: Anuraag Agrawal <[email protected]>
1 parent d9fd56e commit 5377386

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/connectrpc/_server_async.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ async def __call__(
128128
return None
129129
else:
130130
service = cast("_SVC", self._service)
131-
if (state := scope.get("state")) is not None:
132-
state["endpoints"] = self._resolve_endpoints(service)
131+
self._resolved_endpoints = self._resolve_endpoints(service)
133132
await send({"type": "lifespan.startup.complete"})
134133
case "lifespan.shutdown":
135134
if service_iter is not None:
@@ -145,18 +144,15 @@ async def __call__(
145144
await send({"type": "lifespan.shutdown.complete"})
146145
return None
147146

148-
if state := scope.get("state"):
149-
endpoints: Mapping[str, Endpoint] = state["endpoints"]
150-
else:
151-
if not self._resolved_endpoints:
152-
if inspect.isasyncgen(self._service):
153-
msg = "ASGI server does not support lifespan but async generator passed for service. Enable lifespan support."
154-
raise RuntimeError(msg)
147+
if not self._resolved_endpoints:
148+
if inspect.isasyncgen(self._service):
149+
msg = "ASGI server does not support lifespan but async generator passed for service. Enable lifespan support."
150+
raise RuntimeError(msg)
155151

156-
self._resolved_endpoints = self._resolve_endpoints(
157-
cast("_SVC", self._service)
158-
)
159-
endpoints = self._resolved_endpoints
152+
self._resolved_endpoints = self._resolve_endpoints(
153+
cast("_SVC", self._service)
154+
)
155+
endpoints = self._resolved_endpoints
160156

161157
ctx: RequestContext | None = None
162158
try:

0 commit comments

Comments
 (0)