code: def state(self) -> SessionState:
          
          if self.session_id is None:
              raise ValueError("session not yet started")
          session = self.client.get_session(self.session_id)
          if session is None:
              raise ValueError("session not found - it may have been shut down")
          return session.state
docs: The state of the managed Spark session.