def __heartbeat_loop(self):
        send_time = monotonic()

        while self.running:
            time.sleep(self.sleep_time)

            now = monotonic()

            if self.send_sleep != 0 and now - send_time > self.send_sleep:
                send_time = now
                log.debug("Sending a heartbeat message at %s", now)
                try:
                    self.transport.transmit(utils.Frame(None, {}, None))
                except exception.NotConnectedException:
                    log.debug("Lost connection, unable to send heartbeat")
                except Exception:
                    _, e, _ = sys.exc_info()
                    log.debug("Unable to send heartbeat, due to: %s", e)

            if self.receive_sleep != 0:
                diff_receive = now - self.received_heartbeat

                if diff_receive > self.receive_sleep:
                    # heartbeat timeout
                    log.warning("Heartbeat timeout: diff_receive=%s, time=%s, lastrec=%s", diff_receive, now, self.received_heartbeat)
                    self.transport.disconnect_socket()
                    self.transport.set_connected(False)
                    for listener in self.transport.listeners.values():
                        listener.on_heartbeat_timeout()
Main loop for sending (and monitoring received) heartbeats.
dataset/ETHPy150Open jasonrbriggs/stomp.py/stomp/listener.py/HeartbeatListener.__heartbeat_loop