

def heartbeat_loop(self):
    while True:
        start = time.monotonic()
        channel = self.server.ping(self.endpoint)
        error = False
        try:
            channel.get(timeout=self.heartbeat_interval)
        except RpcError as e:
            logger.debug('hearbeat error on %s: %r', self, e)
            error = True
        took = (time.monotonic() - start)
        if (not error):
            self.heartbeat_samples.add(took)
            self.explicit_heartbeat_count += 1
        gevent.sleep(max(0, (self.heartbeat_interval - took)))

dataset/ETHPy150Open deliveryhero/lymph/lymph/core/connection.py Connection.heartbeat_loop/original