class_docstr: Configures worker watchdog timer and handles periodic pings.
  
  Usage:
    # Ping workers every minute, shutting down workers if they haven't received
    # a ping after 1 hour.
    watchdog_manager = WatchdogManager(
      ping_interval=60, shutdown_timeout=3600
    )
  
    # Use as a context manager, resetting watchdog on context exit:
    with watchdog_manager:
      session.run(...)
  
    # Or setup globally; watchdog will remain active until program exit.
    watchdog_manager.configure_and_run()
class_docstr_tok: ["Configures","worker","watchdog","timer","and","handles","periodic","pings",".","Usage",":","#","Ping","workers","every","minute",",","shutting","down","workers","if","they","have","n't","received","#","a","ping","after","1","hour",".","watchdog_manager","=","WatchdogManager","(","ping_interval=60",",","shutdown_timeout=3600",")","#","Use","as","a","context","manager",",","resetting","watchdog","on","context","exit",":","with","watchdog_manager",":","session.run","(","...",")","#","Or","setup","globally",";","watchdog","will","remain","active","until","program","exit",".","watchdog_manager.configure_and_run","(",")"]
docstr: Initialize a watchdog manager.
  
  Args:
    session: Session connected to worker devices.  A cloned session and graph
      will be created for managing worker pings.
    devices: Set of devices to monitor.  If none, all workers will be
      monitored.
    ping_interval: Time, in seconds, between watchdog pings.
    shutdown_timeout: Time, in seconds, before watchdog timeout.
docstr_tok: ["Initialize","a","watchdog","manager",".","Args",":","session",":","Session","connected","to","worker","devices",".","A","cloned","session","and","graph","will","be","created","for","managing","worker","pings",".","devices",":","Set","of","devices","to","monitor",".","If","none",",","all","workers","will","be","monitored",".","ping_interval",":","Time",",","in","seconds",",","between","watchdog","pings",".","shutdown_timeout",":","Time",",","in","seconds",",","before","watchdog","timeout","."]
code: def __init__(
      self,
      session,
      devices=None,
      ping_interval=60,
      shutdown_timeout=2 * 3600,
  ):
      """Initialize a watchdog manager.
  
      Args:
        session: Session connected to worker devices.  A cloned session and graph
          will be created for managing worker pings.
        devices: Set of devices to monitor.  If none, all workers will be
          monitored.
        ping_interval: Time, in seconds, between watchdog pings.
        shutdown_timeout: Time, in seconds, before watchdog timeout.
      """
      threading.Thread.__init__(self)
      self.ping_interval = ping_interval
      self.shutdown_timeout = shutdown_timeout
      self.daemon = True
      self._config = session._config  # pylint: disable=protected-access
      self._target = session.sess_str
      self._running = False
      self._devices = devices
  
      self._graph = None
      self._session = None
      self._worker_manager = None
  
imports: import threading
  import time
  from google.protobuf import text_format
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.util import event_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.tpu.ops import tpu_ops
  from tensorflow.python.training import session_run_hook
  from tensorflow.python.training import training_util
label_desc: Use image node_id 1 to create a new WatchdogManager object from inherited base classes: threading with example: obj = WatchdogManager(session, devices, ping_interval, shutdown_timeout)