StreamableHttp - stateless server support (#554)

This commit is contained in:
ihrpr 2025-05-02 13:40:21 +01:00 • committed by GitHub
commit 72b66a58b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -479,11 +479,21 @@ class Server(Generic[LifespanResultT]):
# but also make tracing exceptions much easier during testing and when using
# in-process servers.
raise_exceptions: bool = False,
# When True, the server as stateless deployments where
# clients can perform initialization with any node. The client must still follow
# the initialization lifecycle, but can do so with any available node
# rather than requiring initialization for each connection.
stateless: bool = False,
):
async with AsyncExitStack() as stack:
lifespan_context = await stack.enter_async_context(self.lifespan(self))
session = await stack.enter_async_context(
ServerSession(read_stream, write_stream, initialization_options)
ServerSession(
read_stream,
write_stream,
initialization_options,
stateless=stateless,
)
)
async with anyio.create_task_group() as tg: