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