utils.py 628 B

12345678910111213141516171819
  1. from typing import Optional
  2. from ray._raylet import GcsClient, NodeID
  3. class HealthChecker:
  4. def __init__(self, gcs_client: GcsClient, local_node_id: Optional[NodeID] = None):
  5. self._gcs_client = gcs_client
  6. self._local_node_id = local_node_id
  7. async def check_local_raylet_liveness(self) -> bool:
  8. if self._local_node_id is None:
  9. return False
  10. liveness = await self._gcs_client.async_check_alive([self._local_node_id], 0.1)
  11. return liveness[0]
  12. async def check_gcs_liveness(self) -> bool:
  13. await self._gcs_client.async_check_alive([], 0.1)
  14. return True