class_docstr: Hosts an application "instance" (an instantiated Document) for one or more connections.
  
      
class_docstr_tok: ["Hosts","an","application","``","instance","''","(","an","instantiated","Document",")","for","one","or","more","connections","."]
code: def __init__(
      self,
      session_id: ID,
      document: Document,
      io_loop: IOLoop | None = None,
      token: str | None = None,
  ) -> None:
      if session_id is None:
          raise ValueError("Sessions must have an id")
      if document is None:
          raise ValueError("Sessions must have a document")
      self._id = session_id
      self._token = token
      self._document = document
      self._loop = io_loop
      self._subscribed_connections = set()
      self._last_unsubscribe_time = current_time()
      self._lock = locks.Lock()
      self._current_patch_connection = None
      self._document.callbacks.on_change_dispatch_to(self)
      self._callbacks = DocumentCallbackGroup(io_loop)
      self._pending_writes = None
      self._destroyed = False
      self._expiration_requested = False
      self._expiration_blocked_count = 0
  
      wrapped_callbacks = [
          self._wrap_session_callback(cb)
          for cb in self._document.session_callbacks
      ]
      self._callbacks.add_session_callbacks(wrapped_callbacks)
  
imports: from __future__ import annotations
  import logging
  import inspect
  import time
  from copy import copy
  from functools import wraps
  from typing import TYPE_CHECKING, Any, Awaitable, Callable, TypeVar
  from tornado import locks
  from ..events import ConnectionLost
  from ..util.token import generate_jwt_token
  from .callbacks import DocumentCallbackGroup
label_desc: Use image node_id 1 to create a new ServerSession object  with example: obj = ServerSession(session_id, document, io_loop, token)