def main(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) schema_pb2_grpc.add_GatewayServicer_to_server(GatewayServer(), server) server.add_insecure_port('[::]:50051') server.start() try: while True: time.sleep(1) except KeyboardInterrupt: server.stop(0)
def main(): # 创建server线程池,最大是10个线程 server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) # 将GatewayService()加入到server内 schema_pb2_grpc.add_GatewayServicer_to_server(GatewayService(), server) # 添加端口 server.add_insecure_port('[::]:50051') server.start() try: while 1: time.sleep(1) except KeyboardInterrupt: server.stop()