def _send_heartbeat(self, update_frequency=2.0): """Send a heartbeat to the Combiner. """ while True: heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.WORKER)) try: self.connection.SendHeartbeat(heartbeat) except grpc.RpcError as e: status_code = e.code() print("CLIENT heartbeat: GRPC ERROR {} retrying..".format(status_code.name), flush=True) import time time.sleep(update_frequency)
def ListActiveClients(self, request: fedn.ListClientsRequest, context): """ RPC endpoint that returns a ClientList containing the names of all active clients. An active client has sent a status message / responded to a heartbeat request in the last 10 seconds. """ clients = fedn.ClientList() active_clients = self._list_active_clients(request.channel) for client in active_clients: clients.client.append(fedn.Client(name=client, role=fedn.WORKER)) return clients
def _send_heartbeat(self, update_frequency=2.0): while True: heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.WORKER)) try: self.connection.SendHeartbeat(heartbeat) # self.send_status("HEARTBEAT from {}".format(self.client),log_level=fedn.Status.INFO) except grpc.RpcError as e: status_code = e.code() print("CLIENT heartbeat: GRPC ERROR {} retrying..".format(status_code.name), flush=True) import time time.sleep(update_frequency)
def _send_heartbeat(self, update_frequency=2.0): """Send a heartbeat to the combiner. Parameters ---------- update_frequency : float The interval in seconds between heartbeat messages. """ while True: heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.WORKER)) try: self.connection.SendHeartbeat(heartbeat) self._missed_heartbeat = 0 except grpc.RpcError as e: status_code = e.code() print("CLIENT heartbeat: GRPC ERROR {} retrying..".format(status_code.name), flush=True) self._handle_combiner_failure() time.sleep(update_frequency) if not self._attached: return