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):
|
if not await self._validate_request_headers(request, send):
|
||||||
return
|
return
|
||||||
|
|
||||||
await self._terminate_session()
|
await self.terminate()
|
||||||
|
|
||||||
response = self._create_json_response(
|
response = self._create_json_response(
|
||||||
None,
|
None,
|
||||||
|
|
@ -620,7 +620,7 @@ class StreamableHTTPServerTransport:
|
||||||
)
|
)
|
||||||
await response(request.scope, request.receive, send)
|
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.
|
"""Terminate the current session, closing all streams.
|
||||||
|
|
||||||
Once terminated, all requests with this session ID will receive 404 Not Found.
|
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
|
# Handle the HTTP request and return the response
|
||||||
await http_transport.handle_request(scope, receive, send)
|
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(
|
async def _handle_stateful_request(
|
||||||
self,
|
self,
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue