feat(backend_server.py): set client status to STALE if offline for >24h

This commit is contained in:
2026-02-28 23:40:03 +01:00
parent b1656cdfa9
commit de9240e6e0

View File

@@ -293,6 +293,15 @@ class BackendServer:
self._accept_connection(key.fileobj) # type: ignore
else:
self._handle_connection(key, mask)
# update client statuses
now = time.time()
for client in self.clients.values():
if (
client.status == ClientStatus.OFFLINE
and now - client.last_seen > 60 * 60 * 24 # 24 hours
):
self.clients[client.id].status = ClientStatus.STALE
time.sleep(0.001) # prevent 100% CPU usage
except Exception as e: