class_docstr: An interface for communicating with a ScriptRunner. Thread-safe.
  
  AppSession makes requests of a ScriptRunner through this class, and
  ScriptRunner handles those requests.
class_docstr_tok: ["An","interface","for","communicating","with","a","ScriptRunner",".","Thread-safe",".","AppSession","makes","requests","of","a","ScriptRunner","through","this","class",",","and","ScriptRunner","handles","those","requests","."]
docstr: Called by the ScriptRunner when it's at a yield point.
  
  If we have no request, return None.
  
  If we have a RERUN request, return the request and set our internal
  state to CONTINUE.
  
  If we have a STOP request, return the request and remain stopped.
docstr_tok: ["Called","by","the","ScriptRunner","when","it","'s","at","a","yield","point",".","If","we","have","no","request",",","return","None",".","If","we","have","a","RERUN","request",",","return","the","request","and","set","our","internal","state","to","CONTINUE",".","If","we","have","a","STOP","request",",","return","the","request","and","remain","stopped","."]
code: def on_scriptrunner_yield(self) -> Optional[ScriptRequest]:
      """Called by the ScriptRunner when it's at a yield point.
  
      If we have no request, return None.
  
      If we have a RERUN request, return the request and set our internal
      state to CONTINUE.
  
      If we have a STOP request, return the request and remain stopped.
      """
      if self._state == ScriptRequestType.CONTINUE:
          # We avoid taking a lock in the common case. If a STOP or RERUN
          # request is received between the `if` and `return`, it will be
          # handled at the next `on_scriptrunner_yield`, or when
          # `on_scriptrunner_ready` is called.
          return None
  
      with self._lock:
          if self._state == ScriptRequestType.RERUN:
              self._state = ScriptRequestType.CONTINUE
              return ScriptRequest(
                  ScriptRequestType.RERUN, self._rerun_data
              )
  
          assert self._state == ScriptRequestType.STOP
          return ScriptRequest(ScriptRequestType.STOP)
  
imports: import threading
  from dataclasses import dataclass
  from enum import Enum
  from typing import Optional, cast
  from streamlit import util
  from streamlit.proto.WidgetStates_pb2 import WidgetStates
  from streamlit.runtime.state import coalesce_widget_states
label_desc: Use image node_id 4 for calling the ScriptRequests obj's underlying member method code with example usage: obj.on_scriptrunner_yield() and returns: None, ScriptRequest, ScriptRequest