ForewordgRPCexample测试安装gRPC库pip install grpcio安装gRPC工具pip install grpcio-tools下载官方例程git clone -b v1.66.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc演示用例在这里grpc/examples/python/helloworld先启动服务端python greeter_server.py可以看到已经在监听了再启动客户端python greeter_client.py正常连接到了服务端源码分析服务端fromconcurrentimportfuturesimportloggingimportgrpcimporthelloworld_pb2importhelloworld_pb2_grpc# 继承自helloworld_pb2_grpc.GreeterServicer,重写了sayhello的函数classGreeter(helloworld_pb2_grpc.GreeterServicer):defSayHello(self,request,context):# 对应返回 hello 和访问者的名字returnhelloworld_pb2.HelloReply(message="Hello, %s!"%reque
...
继续阅读
(52)