From 99fcb30b173df1a9200fcab7bedbfbb193d2c070 Mon Sep 17 00:00:00 2001 From: pengdake <19921207pq@gmail.com> Date: Wed, 31 Jan 2018 18:09:00 +0800 Subject: [PATCH] Delete function named poll_until which never used. Change-Id: I60a314876f26a403894e3782301348d209e35b0b --- zun/common/utils.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/zun/common/utils.py b/zun/common/utils.py index 2bed6aa8f..db7daeb96 100644 --- a/zun/common/utils.py +++ b/zun/common/utils.py @@ -19,13 +19,11 @@ import eventlet import functools import mimetypes -import time from oslo_concurrency import lockutils from oslo_concurrency import processutils from oslo_context import context as common_context from oslo_log import log as logging -from oslo_service import loopingcall from oslo_utils import strutils import pecan import six @@ -216,37 +214,6 @@ def check_container_id(function): return decorated_function -def poll_until(retriever, condition=lambda value: value, - sleep_time=1, time_out=None, success_msg=None, - timeout_msg=None): - """Retrieves object until it passes condition, then returns it. - - If time_out_limit is passed in, PollTimeOut will be raised once that - amount of time is elapsed. - """ - start_time = time.time() - - def poll_and_check(): - obj = retriever() - if condition(obj): - raise loopingcall.LoopingCallDone(retvalue=obj) - if time_out is not None and time.time() - start_time > time_out: - raise exception.PollTimeOut - - try: - poller = loopingcall.FixedIntervalLoopingCall( - f=poll_and_check).start(sleep_time, initial_delay=False) - poller.wait() - LOG.info(success_msg) - except exception.PollTimeOut: - LOG.error(timeout_msg) - raise - except Exception as e: - LOG.exception("Unexpected exception occurred: %s", - six.text_type(e)) - raise - - def get_image_pull_policy(image_pull_policy, image_tag): if not image_pull_policy: if image_tag == 'latest':