| Index: telemetry/telemetry/core/util.py
|
| diff --git a/telemetry/telemetry/core/util.py b/telemetry/telemetry/core/util.py
|
| index 41ce857b9f59f6ceba963993b5b4c12c256213ce..cf44603a96684cfc59e5b3ee858ee82ce2f4f8d4 100644
|
| --- a/telemetry/telemetry/core/util.py
|
| +++ b/telemetry/telemetry/core/util.py
|
| @@ -3,16 +3,13 @@
|
| # found in the LICENSE file.
|
| import glob
|
| import imp
|
| -import inspect
|
| -import logging
|
| import os
|
| import socket
|
| import sys
|
| -import time
|
|
|
| -import py_utils as catapult_util # pylint: disable=import-error
|
| +from telemetry import decorators
|
|
|
| -from telemetry.core import exceptions
|
| +import py_utils as catapult_util # pylint: disable=import-error
|
|
|
|
|
| IsRunningOnCrosDevice = catapult_util.IsRunningOnCrosDevice
|
| @@ -60,45 +57,12 @@ def GetPythonPageSetModule(file_path):
|
| return imp.load_source(_GetUniqueModuleName(), file_path)
|
|
|
|
|
| +@decorators.Deprecated(
|
| + 2017, 6, 1,
|
| + 'telemetry.core.utils.WaitFor() is being deprecated. Please use '
|
| + 'catapult.common.py_utils.WaitFor() instead.')
|
| def WaitFor(condition, timeout):
|
| - """Waits for up to |timeout| secs for the function |condition| to return True.
|
| -
|
| - Polling frequency is (elapsed_time / 10), with a min of .1s and max of 5s.
|
| -
|
| - Returns:
|
| - Result of |condition| function (if present).
|
| - """
|
| - min_poll_interval = 0.1
|
| - max_poll_interval = 5
|
| - output_interval = 300
|
| -
|
| - def GetConditionString():
|
| - if condition.__name__ == '<lambda>':
|
| - try:
|
| - return inspect.getsource(condition).strip()
|
| - except IOError:
|
| - pass
|
| - return condition.__name__
|
| -
|
| - start_time = time.time()
|
| - last_output_time = start_time
|
| - while True:
|
| - res = condition()
|
| - if res:
|
| - return res
|
| - now = time.time()
|
| - elapsed_time = now - start_time
|
| - last_output_elapsed_time = now - last_output_time
|
| - if elapsed_time > timeout:
|
| - raise exceptions.TimeoutException('Timed out while waiting %ds for %s.' %
|
| - (timeout, GetConditionString()))
|
| - if last_output_elapsed_time > output_interval:
|
| - logging.info('Continuing to wait %ds for %s. Elapsed: %ds.', timeout,
|
| - GetConditionString(), elapsed_time)
|
| - last_output_time = time.time()
|
| - poll_interval = min(
|
| - max(elapsed_time / 10., min_poll_interval), max_poll_interval)
|
| - time.sleep(poll_interval)
|
| + return catapult_util.WaitFor(condition, timeout)
|
|
|
|
|
| class PortKeeper(object):
|
|
|