Skip to content

Commit

Permalink
Fixed statistics API (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
danyi1212 committed Jul 16, 2024
1 parent ff0f350 commit 3801481
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/opal-server/opal_server/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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")
Expand Down

0 comments on commit 3801481

Please sign in to comment.