Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhellander committed May 15, 2024
1 parent d9b83d1 commit a256c44
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions fedn/network/combiner/combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def __init__(self, config):
for client in previous_clients:
self.statestore.set_client({"name": client["name"], "status": "offline"})

print("Previous clients: {}".format(self.clients))

self.modelservice = ModelService()

# Create gRPC server
Expand Down Expand Up @@ -328,13 +326,10 @@ def _list_active_clients(self, channel):
"update_active_clients": [],
"update_offline_clients": [],
}
print(self._list_subscribed_clients(channel))
for client in self._list_subscribed_clients(channel):
status = self.clients[client]["status"]
print("Client: {}, status={}".format(client, status))
now = datetime.now()
then = self.clients[client]["lastseen"]
print("Time since seen: {}".format(now - then))
if (now - then) < timedelta(seconds=10):
clients["active_clients"].append(client)
# If client has changed status, update statestore
Expand All @@ -346,15 +341,13 @@ def _list_active_clients(self, channel):
clients["update_offline_clients"].append(client)
# Update statestore with client status
if len(clients["update_active_clients"]) > 0:
print("Updating active clients: {}".format(clients["update_active_clients"]))
self.statestore.update_client_status(clients["update_active_clients"], "online")
if len(clients["update_offline_clients"]) > 0:
print("Updating offline clients: {}".format(clients["update_offline_clients"]))
self.statestore.update_client_status(clients["update_offline_clients"], "offline")

return clients["active_clients"]

def _deamon_thread_client_status(self, timeout=10):
def _deamon_thread_client_status(self, timeout=5):
"""Deamon thread that checks for inactive clients and updates statestore."""
while True:
time.sleep(timeout)
Expand Down

0 comments on commit a256c44

Please sign in to comment.