From 4d3259584cc1efe6dbadea112737434b2f150888 Mon Sep 17 00:00:00 2001 From: Dan Yishai Date: Tue, 16 Jul 2024 12:00:43 +0300 Subject: [PATCH] Fixed statistics API --- packages/opal-server/opal_server/statistics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opal-server/opal_server/statistics.py b/packages/opal-server/opal_server/statistics.py index 6ae5ad61..14ea97f0 100644 --- a/packages/opal-server/opal_server/statistics.py +++ b/packages/opal-server/opal_server/statistics.py @@ -124,9 +124,9 @@ async def _expire_old_servers(self): now = datetime.utcnow() still_alive = {} for server_id, last_seen in self._seen_servers.items(): - if ( - now - last_seen - ).total_seconds() < opal_server_config.STATISTICS_SERVER_KEEPALIVE_TIMEOUT: + if (now - last_seen).total_seconds() < float( + opal_server_config.STATISTICS_SERVER_KEEPALIVE_TIMEOUT + ): still_alive[server_id] = last_seen self._seen_servers = still_alive self._state.servers = {self._worker_id} | set(self._seen_servers.keys()) @@ -140,7 +140,7 @@ async def _periodic_server_keepalive(self): ServerKeepalive(worker_id=self._worker_id).dict(), ) await asyncio.sleep( - opal_server_config.STATISTICS_SERVER_KEEPALIVE_TIMEOUT / 2 + float(opal_server_config.STATISTICS_SERVER_KEEPALIVE_TIMEOUT) / 2 ) except asyncio.CancelledError: logger.debug("Statistics: periodic server keepalive cancelled")