class_docstr: Contains session data for a single "user" of an active app
  (that is, a connected browser tab).
  
  Each AppSession has its own ScriptData, root DeltaGenerator, ScriptRunner,
  and widget state.
  
  An AppSession is attached to each thread involved in running its script.
class_docstr_tok: ["Contains","session","data","for","a","single","``","user","''","of","an","active","app","(","that","is",",","a","connected","browser","tab",")",".","Each","AppSession","has","its","own","ScriptData",",","root","DeltaGenerator",",","ScriptRunner",",","and","widget","state",".","An","AppSession","is","attached","to","each","thread","involved","in","running","its","script","."]
docstr: Handle an Exception raised while processing a BackMsg from the browser.
docstr_tok: ["Handle","an","Exception","raised","while","processing","a","BackMsg","from","the","browser","."]
code: def handle_backmsg_exception(self, e: BaseException) -> None:
      """Handle an Exception raised while processing a BackMsg from the browser."""
      # This does a few things:
      # 1) Clears the current app in the browser.
      # 2) Marks the current app as "stopped" in the browser.
      # 3) HACK: Resets any script params that may have been broken (e.g. the
      # command-line when rerunning with wrong argv[0])
  
      self._on_scriptrunner_event(
          self._scriptrunner,
          ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS,
      )
      self._on_scriptrunner_event(
          self._scriptrunner,
          ScriptRunnerEvent.SCRIPT_STARTED,
          page_script_hash="",
      )
      self._on_scriptrunner_event(
          self._scriptrunner,
          ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS,
      )
  
      # Send an Exception message to the frontend.
      # Because _on_scriptrunner_event does its work in an eventloop callback,
      # this exception ForwardMsg *must* also be enqueued in a callback,
      # so that it will be enqueued *after* the various ForwardMsgs that
      # _on_scriptrunner_event sends.
      self._event_loop.call_soon_threadsafe(
          lambda: self._enqueue_forward_msg(
              self._create_exception_message(e)
          )
      )
  
imports: import asyncio
  import sys
  import uuid
  from enum import Enum
  from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union
  import streamlit.elements.exception
  from streamlit import config, runtime, source_util
  from streamlit.case_converters import to_snake_case
  from streamlit.logger import get_logger
  from streamlit.proto.BackMsg_pb2 import BackMsg
  from streamlit.proto.ClientState_pb2 import ClientState
  from streamlit.proto.Common_pb2 import FileURLs, FileURLsRequest
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.proto.GitInfo_pb2 import GitInfo
  from streamlit.proto.NewSession_pb2 import Config, CustomThemeConfig, NewSession, UserInfo
  from streamlit.proto.PagesChanged_pb2 import PagesChanged
  from streamlit.runtime import caching, legacy_caching
  from streamlit.runtime.forward_msg_queue import ForwardMsgQueue
  from streamlit.runtime.metrics_util import Installation
  from streamlit.runtime.script_data import ScriptData
  from streamlit.runtime.scriptrunner import RerunData, ScriptRunner, ScriptRunnerEvent
  from streamlit.runtime.scriptrunner.script_cache import ScriptCache
  from streamlit.runtime.secrets import secrets_singleton
  from streamlit.runtime.uploaded_file_manager import UploadedFileManager
  from streamlit.version import STREAMLIT_VERSION_STRING
  from streamlit.watcher import LocalSourcesWatcher
label_desc: Use image node_id 9 for calling the AppSession obj's underlying member method code with example usage: obj.handle_backmsg_exception(e) without return types