Source code for csle_common.util.grpc_util
import grpc
[docs]class GrpcUtil:
"""
Class with utility functions for GRPC functionality in CSLE
"""
[docs] @staticmethod
def grpc_server_on(channel) -> bool:
"""
Utility function to test if a given gRPC channel is working or not
:param channel: the channel to test
:return: True if working, False if timeout
"""
try:
grpc.channel_ready_future(channel).result(timeout=15)
return True
except grpc.FutureTimeoutError:
return False