class_docstr: A simple ping-pong style heartbeat that runs in a thread.
class_docstr_tok: ["A","simple","ping-pong","style","heartbeat","that","runs","in","a","thread","."]
docstr: Run the heartbeat thread.
docstr_tok: ["Run","the","heartbeat","thread","."]
code: def run(self):
      """Run the heartbeat thread."""
      self.name = "Heartbeat"
      self.socket = self.context.socket(zmq.ROUTER)
      self.socket.linger = 1000
      try:
          self._bind_socket()
      except Exception:
          self.socket.close()
          raise
  
      while True:
          try:
              zmq.device(zmq.QUEUE, self.socket, self.socket)
          except zmq.ZMQError as e:
              if e.errno == errno.EINTR:
                  # signal interrupt, resume heartbeat
                  continue
              if e.errno == zmq.ETERM:
                  # context terminated, close socket and exit
                  try:
                      self.socket.close()
                  except zmq.ZMQError:
                      # suppress further errors during cleanup
                      # this shouldn't happen, though
                      pass
                  break
              if e.errno == zmq.ENOTSOCK:
                  # socket closed elsewhere, exit
                  break
              raise
          else:
              break
  
file_path: catboost/contrib/python/ipykernel/py3/ipykernel/heartbeat.py
imports: import errno
  import socket
  from pathlib import Path
  from threading import Thread
  import zmq
  from jupyter_client.localinterfaces import localhost
label_desc: Use image node_id 5 for calling the Heartbeat obj's underlying member method code with example usage: obj.run() without return types