class_docstr: A Windows-specific daemon thread that listens for a special event that
  signals an interrupt and, optionally, terminates the program immediately
  when the parent process no longer exists.
class_docstr_tok: ["A","Windows-specific","daemon","thread","that","listens","for","a","special","event","that","signals","an","interrupt","and",",","optionally",",","terminates","the","program","immediately","when","the","parent","process","no","longer","exists","."]
docstr: Run the poll loop. This method never returns.
docstr_tok: ["Run","the","poll","loop",".","This","method","never","returns","."]
code: def run(self):
      """Run the poll loop. This method never returns."""
      try:
          from _winapi import (
              INFINITE,
              WAIT_OBJECT_0,
          )  # type:ignore[attr-defined]
      except ImportError:
          from _subprocess import INFINITE, WAIT_OBJECT_0
  
      # Build the list of handle to listen on.
      handles = []
      if self.interrupt_handle:
          handles.append(self.interrupt_handle)
      if self.parent_handle:
          handles.append(self.parent_handle)
      arch = platform.architecture()[0]
      c_int = ctypes.c_int64 if arch.startswith("64") else ctypes.c_int
  
      # Listen forever.
      while True:
          result = ctypes.windll.kernel32.WaitForMultipleObjects(  # type:ignore[attr-defined]
              len(handles),  # nCount
              (c_int * len(handles))(*handles),  # lpHandles
              False,  # bWaitAll
              INFINITE,
          )  # dwMilliseconds
  
          if WAIT_OBJECT_0 <= result < len(handles):
              handle = handles[result - WAIT_OBJECT_0]
  
              if handle == self.interrupt_handle:
                  # check if signal handler is callable
                  # to avoid 'int not callable' error (Python issue #23395)
                  if callable(signal.getsignal(signal.SIGINT)):
                      interrupt_main()
  
              elif handle == self.parent_handle:
                  get_logger().warning(
                      "Parent appears to have exited, shutting down."
                  )
                  os._exit(1)
          elif result < 0:
              # wait failed, just give up and stop polling.
              warnings.warn(
                  """Parent poll failed.  If the frontend dies,
                  the kernel may be left running.  Please let us know
                  about your system (bitness, Python, etc.) at
                  ipython-dev@scipy.org""",
                  stacklevel=2,
              )
              return
  
file_path: catboost/contrib/python/ipykernel/py3/ipykernel/parentpoller.py
imports: import os
  import platform
  import signal
  import time
  import warnings
  from _thread import interrupt_main
  from threading import Thread
  from traitlets.log import get_logger
label_desc: Use image node_id 2 for calling the ParentPollerWindows obj's underlying member method code with example usage: obj.run() without return types