Close server session after handle stateless request (#1116)
This commit is contained in:
parent
a10fec7fa6
commit
b8cb3675dc
2 changed files with 5 additions and 2 deletions
|
|
@ -612,7 +612,7 @@ class StreamableHTTPServerTransport:
|
|||
if not await self._validate_request_headers(request, send):
|
||||
return
|
||||
|
||||
await self._terminate_session()
|
||||
await self.terminate()
|
||||
|
||||
response = self._create_json_response(
|
||||
None,
|
||||
|
|
@ -620,7 +620,7 @@ class StreamableHTTPServerTransport:
|
|||
)
|
||||
await response(request.scope, request.receive, send)
|
||||
|
||||
async def _terminate_session(self) -> None:
|
||||
async def terminate(self) -> None:
|
||||
"""Terminate the current session, closing all streams.
|
||||
|
||||
Once terminated, all requests with this session ID will receive 404 Not Found.
|
||||
|
|
|
|||
|
|
@ -190,6 +190,9 @@ class StreamableHTTPSessionManager:
|
|||
# Handle the HTTP request and return the response
|
||||
await http_transport.handle_request(scope, receive, send)
|
||||
|
||||
# Terminate the transport after the request is handled
|
||||
await http_transport.terminate()
|
||||
|
||||
async def _handle_stateful_request(
|
||||
self,
|
||||
scope: Scope,
|
||||
|
|
|
|||
Loading…
Reference in a new issue