def serving_server(self): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) Serving.add_ServingServiceServicer_to_server(ServingServicer(), server) server.add_insecure_port("[::]:50052") server.start() yield server server.stop(0)
def secure_serving_server(self, server_credentials): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) Serving.add_ServingServiceServicer_to_server(ServingServicer(), server) port = find_free_port() server.add_secure_port(f"[::]:{port}", server_credentials) server.start() yield port server.stop(0)
def serve(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) Serving.add_ServingServiceServicer_to_server(ServingServicer(), server) server.add_insecure_port("[::]:50052") server.start() try: while True: time.sleep(_ONE_DAY_IN_SECONDS) except KeyboardInterrupt: server.stop(0)