refactor(server.py): fix method naming and add logging
This commit is contained in:
@@ -32,19 +32,22 @@ class BackendServer:
|
||||
|
||||
self.running: bool = False
|
||||
|
||||
def start_polling(self) -> None:
|
||||
def run(self) -> None:
|
||||
self.running = True
|
||||
threading.Thread(
|
||||
name="BackendServer thread", target=self._poll_loop, daemon=True
|
||||
name="BackendServer thread", target=self._loop, daemon=True
|
||||
).start()
|
||||
|
||||
def _poll_loop(self) -> None:
|
||||
def _loop(self) -> None:
|
||||
self.logger.info("Starting server loop...")
|
||||
while self.running:
|
||||
for client in self.clients.values():
|
||||
client["polled"]["cpu_usage"] = round(rn.uniform(0, 100), 1)
|
||||
client["polled"]["ram_usage"] = round(rn.uniform(0, 100), 1)
|
||||
time.sleep(1)
|
||||
|
||||
self.logger.info("Server loop stopped.")
|
||||
|
||||
def get_client_data(
|
||||
self, client_id: str
|
||||
) -> dict[str, dict[str, Any]] | None:
|
||||
|
||||
Reference in New Issue
Block a user