docstr: Initialize the ScriptRunner.
  
  (The ScriptRunner won't start executing until start() is called.)
  
  Parameters
  ----------
  session_id
      The AppSession's id.
  
  main_script_path
      Path to our main app script.
  
  uploaded_file_mgr
      The File manager to store the data uploaded by the file_uploader widget.
  
  script_cache
      A ScriptCache instance.
  
  user_info
      A dict that contains information about the current user. For now,
      it only contains the user's email address.
  
      {
          "email": "example@example.com"
      }
  
      Information about the current user is optionally provided when a
      websocket connection is initialized via the "X-Streamlit-User" header.
docstr_tok: ["Initialize","the","ScriptRunner",".","(","The","ScriptRunner","wo","n't","start","executing","until","start","(",")","is","called",".",")","Parameters","--","--","--","--","--","session_id","The","AppSession","'s","id",".","main_script_path","Path","to","our","main","app","script",".","uploaded_file_mgr","The","File","manager","to","store","the","data","uploaded","by","the","file_uploader","widget",".","script_cache","A","ScriptCache","instance",".","user_info","A","dict","that","contains","information","about","the","current","user",".","For","now",",","it","only","contains","the","user","'s","email","address",".","{","``","email","''",":","``","example","@","example.com","''","}","Information","about","the","current","user","is","optionally","provided","when","a","websocket","connection","is","initialized","via","the","``","X-Streamlit-User","''","header","."]
code: def __init__(
      self,
      session_id: str,
      main_script_path: str,
      session_state: SessionState,
      uploaded_file_mgr: UploadedFileManager,
      script_cache: ScriptCache,
      initial_rerun_data: RerunData,
      user_info: Dict[str, Optional[str]],
  ):
      """Initialize the ScriptRunner.
  
      (The ScriptRunner won't start executing until start() is called.)
  
      Parameters
      ----------
      session_id
          The AppSession's id.
  
      main_script_path
          Path to our main app script.
  
      uploaded_file_mgr
          The File manager to store the data uploaded by the file_uploader widget.
  
      script_cache
          A ScriptCache instance.
  
      user_info
          A dict that contains information about the current user. For now,
          it only contains the user's email address.
  
          {
              "email": "example@example.com"
          }
  
          Information about the current user is optionally provided when a
          websocket connection is initialized via the "X-Streamlit-User" header.
  
      """
      self._session_id = session_id
      self._main_script_path = main_script_path
      self._uploaded_file_mgr = uploaded_file_mgr
      self._script_cache = script_cache
      self._user_info = user_info
  
      self._session_state = SafeSessionState(
          session_state,
          yield_callback=self._maybe_handle_execution_control_request,
      )
  
      self._requests = ScriptRequests()
      self._requests.request_rerun(initial_rerun_data)
  
      self.on_event = Signal(
          doc="""Emitted when a ScriptRunnerEvent occurs.
  
              This signal is generally emitted on the ScriptRunner's script
              thread (which is *not* the same thread that the ScriptRunner was
              created on).
  
              Parameters
              ----------
              sender: ScriptRunner
                  The sender of the event (this ScriptRunner).
  
              event : ScriptRunnerEvent
  
              forward_msg : ForwardMsg | None
                  The ForwardMsg to send to the frontend. Set only for the
                  ENQUEUE_FORWARD_MSG event.
  
              exception : BaseException | None
                  Our compile error. Set only for the
                  SCRIPT_STOPPED_WITH_COMPILE_ERROR event.
  
              widget_states : streamlit.proto.WidgetStates_pb2.WidgetStates | None
                  The ScriptRunner's final WidgetStates. Set only for the
                  SHUTDOWN event.
              """
      )
  
      # Set to true while we're executing. Used by
      # _maybe_handle_execution_control_request.
      self._execing = False
  
      # This is initialized in start()
      self._script_thread: Optional[threading.Thread] = None
  
imports: import gc
  import sys
  import threading
  import types
  from contextlib import contextmanager
  from enum import Enum
  from timeit import default_timer
  from typing import Callable, Dict, Optional
  from blinker import Signal
  from streamlit import config, runtime, source_util, util
  from streamlit.error_util import handle_uncaught_app_exception
  from streamlit.logger import get_logger
  from streamlit.proto.ClientState_pb2 import ClientState
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.runtime.scriptrunner.script_cache import ScriptCache
  from streamlit.runtime.scriptrunner.script_requests import RerunData, ScriptRequests, ScriptRequestType
  from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext, add_script_run_ctx, get_script_run_ctx
  from streamlit.runtime.state import SCRIPT_RUN_WITHOUT_ERRORS_KEY, SafeSessionState, SessionState
  from streamlit.runtime.uploaded_file_manager import UploadedFileManager
  from streamlit.vendor.ipython.modified_sys_path import modified_sys_path
label_desc: Use image node_id 1 to create a new ScriptRunner object  with example: obj = ScriptRunner(session_id, main_script_path, session_state, uploaded_file_mgr, script_cache, initial_rerun_data, user_info)