nanover.utilities.grpc_utilities module

Utilities for working with GRPC, particularly wrappers with more descriptive names.

exception nanover.utilities.grpc_utilities.RpcAlreadyTerminatedError

Bases: Exception

nanover.utilities.grpc_utilities.subscribe_channel_connectivity_change(channel: Channel, callback: Callable[[ChannelConnectivity], None], force_connection: bool = False)

Subscribe to channel connectivity changes with a callback that is called with the channel’s latest connectivity status. Optionally force the channel to begin connecting instead of waiting for an RPC attempt.

Warning

On channel close, all subscriptions are removed without state change.

nanover.utilities.grpc_utilities.subscribe_rpc_termination(context: RpcContext, callback: Callable[[], None])

Subscribe the termination of an RPC with the given callback.

Raises:

RpcAlreadyTerminatedError – if the callback will not be used because termination has already occurred.