class_docstr: A simple ping-pong style heartbeat that runs in a thread.
code: def __init__(self, context, addr=None):
      if addr is None:
          addr = ("tcp", localhost(), 0)
      Thread.__init__(self)
      self.context = context
      self.transport, self.ip, self.port = addr
      if self.port == 0:
          if addr[0] == "tcp":
              s = socket.socket()
              # '*' means all interfaces to 0MQ, which is '' to socket.socket
              s.bind(("" if self.ip == "*" else self.ip, 0))
              self.port = s.getsockname()[1]
              s.close()
          elif addr[0] == "ipc":
              self.port = 1
              while os.path.exists("%s-%s" % (self.ip, self.port)):
                  self.port = self.port + 1
          else:
              raise ValueError(
                  "Unrecognized zmq transport: %s" % addr[0]
              )
      self.addr = (self.ip, self.port)
      self.daemon = True
  
file_path: catboost/contrib/python/ipykernel/py2/ipykernel/heartbeat.py
imports: import errno
  import os
  import socket
  from threading import Thread
  import zmq
  from jupyter_client.localinterfaces import localhost
label_desc: Use image node_id 1 to create a new Heartbeat object from inherited base classes: Thread with example: obj = Heartbeat(context, addr)