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","(",")"]
code: def run(self):
      # Don't fetch logs or adjust timing: just ping the watchdog.
      #
      # If we hit an exception, reset our session as it is likely broken.
      while self._running:
          try:
              self._worker_manager.ping(
                  request=None
              )  # pytype: disable=attribute-error
              time.sleep(self.ping_interval)
          except errors.OpError as e:
              # Catch any TF errors that occur so we don't stop sending heartbeats
              logging.debug(
                  "Caught error while sending heartbeat: %s", e
              )
              self._reset_manager()
  
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 7 for calling the WatchdogManager obj's underlying member method code with example usage: obj.run() without return types