Skip to navigation

nemo_gym.server_runtime.request_handling.session_id

View as MarkdownOpen in Claude

Middleware that gives every request’s session a Gym session ID.

Module Contents

Classes

NameDescription
SessionIDMiddlewareAssign the session ID before the route runs, and settle it when the reply starts.
_ReplyReplacedStops a route whose reply the 409 for another worker’s session replaced, so it streams nothing more.

API

class nemo_gym.server_runtime.request_handling.session_id.SessionIDMiddleware(
app: starlette.types.ASGIApp
)

Assign the session ID before the route runs, and settle it when the reply starts.

SessionMiddleware must wrap this middleware. It puts the session in scope["session"], and writes the cookie when the reply starts, after this middleware has settled the session.

nemo_gym.server_runtime.request_handling.session_id.SessionIDMiddleware.__call__(
scope: starlette.types.Scope,
receive: starlette.types.Receive,
send: starlette.types.Send
) -> None
async
class nemo_gym.server_runtime.request_handling.session_id._ReplyReplaced()
Exception

Bases: Exception

Stops a route whose reply the 409 for another worker’s session replaced, so it streams nothing more.