据我了解,建议在服务器中运行以下代码以启动gRPC服务器:
def serve():
# create a gRPC server
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
greet_service = GreetServiceServicer()
greet_pb2_grpc.add_GreetServiceServicer_to_server(greet_service, server)
print('Starting server. Listening on port 50051.')
server.add_insecure_port('[::]:50051')
server.start()
# since server.start() will not block,
# a sleep-loop is added to keep alive
try:
while True:
time.sleep(86400)
except KeyboardInterrupt:
server.stop(0)
问题: