14 """The Python example of utilizing Channelz feature."""
16 from __future__
import absolute_import
17 from __future__
import division
18 from __future__
import print_function
21 from concurrent
import futures
27 helloworld_pb2, helloworld_pb2_grpc = grpc.protos_and_services(
33 _LOGGER = logging.getLogger(__name__)
34 _LOGGER.setLevel(logging.INFO)
36 _RANDOM_FAILURE_RATE = 0.3
46 context.abort(grpc.StatusCode.UNAVAILABLE,
47 'Randomly injected failure.')
57 channelz.add_channelz_servicer(server)
59 server.add_insecure_port(addr)
64 parser = argparse.ArgumentParser()
65 parser.add_argument(
'--addr',
69 help=
'the address to listen on')
75 help=
'a float indicates the percentage of failed message injections')
76 args = parser.parse_args()
78 server =
create_server(addr=args.addr, failure_rate=args.failure_rate)
80 server.wait_for_termination()
83 if __name__ ==
'__main__':
84 logging.basicConfig(level=logging.INFO)