Provide a deprecated alias for the now removed stop watch class

This allows those who were using it to still continue using it
until 2.0 where it will be removed; this makes it possible for
those users to get off that code in a way that will be easily
do-able (without totally breaking there code-bases, until we do
that in the 2.0 release).

This also removes all internal usage of that stop watch class
so that the library itself will not reference it anymore.

Change-Id: If313d8e7b9bdc8741db2e2e1dfb381aa3260b971
This commit is contained in:
Joshua Harlow
2015-06-26 16:08:19 -07:00
committed by Joshua Harlow
parent 27272a2aa7
commit 9478226141
10 changed files with 20 additions and 23 deletions

View File

@@ -33,7 +33,6 @@ from taskflow import logging
from taskflow import task as task_atom from taskflow import task as task_atom
from taskflow.types import failure from taskflow.types import failure
from taskflow.types import notifier from taskflow.types import notifier
from taskflow.types import timing
from taskflow.utils import async_utils from taskflow.utils import async_utils
from taskflow.utils import threading_utils from taskflow.utils import threading_utils
@@ -176,7 +175,7 @@ class _WaitWorkItem(object):
'kind': _KIND_COMPLETE_ME, 'kind': _KIND_COMPLETE_ME,
} }
if self._channel.put(message): if self._channel.put(message):
watch = timing.StopWatch() watch = timeutils.StopWatch()
watch.start() watch.start()
self._barrier.wait() self._barrier.wait()
LOG.blather("Waited %s seconds until task '%s' %s emitted" LOG.blather("Waited %s seconds until task '%s' %s emitted"
@@ -305,7 +304,7 @@ class _Dispatcher(object):
" %s to target '%s'", kind, sender, target) " %s to target '%s'", kind, sender, target)
def run(self, queue): def run(self, queue):
watch = timing.StopWatch(duration=self._dispatch_periodicity) watch = timeutils.StopWatch(duration=self._dispatch_periodicity)
while (not self._dead.is_set() or while (not self._dead.is_set() or
(self._stop_when_empty and self._targets)): (self._stop_when_empty and self._targets)):
watch.restart() watch.restart()

View File

@@ -28,7 +28,6 @@ from taskflow.engines.action_engine import executor
from taskflow import exceptions as excp from taskflow import exceptions as excp
from taskflow import logging from taskflow import logging
from taskflow.types import failure as ft from taskflow.types import failure as ft
from taskflow.types import timing as tt
from taskflow.utils import schema_utils as su from taskflow.utils import schema_utils as su
# NOTE(skudriashev): This is protocol states and events, which are not # NOTE(skudriashev): This is protocol states and events, which are not
@@ -239,7 +238,7 @@ class Request(Message):
self._event = ACTION_TO_EVENT[action] self._event = ACTION_TO_EVENT[action]
self._arguments = arguments self._arguments = arguments
self._kwargs = kwargs self._kwargs = kwargs
self._watch = tt.StopWatch(duration=timeout).start() self._watch = timeutils.StopWatch(duration=timeout).start()
self._state = WAITING self._state = WAITING
self._lock = threading.Lock() self._lock = threading.Lock()
self._created_on = timeutils.utcnow() self._created_on = timeutils.utcnow()

View File

@@ -17,6 +17,7 @@
import functools import functools
from oslo_utils import reflection from oslo_utils import reflection
from oslo_utils import timeutils
from taskflow.engines.worker_based import dispatcher from taskflow.engines.worker_based import dispatcher
from taskflow.engines.worker_based import protocol as pr from taskflow.engines.worker_based import protocol as pr
@@ -24,7 +25,6 @@ from taskflow.engines.worker_based import proxy
from taskflow import logging from taskflow import logging
from taskflow.types import failure as ft from taskflow.types import failure as ft
from taskflow.types import notifier as nt from taskflow.types import notifier as nt
from taskflow.types import timing as tt
from taskflow.utils import kombu_utils as ku from taskflow.utils import kombu_utils as ku
from taskflow.utils import misc from taskflow.utils import misc
@@ -76,7 +76,7 @@ class Server(object):
def _on_receive(content, message): def _on_receive(content, message):
LOG.debug("Submitting message '%s' for execution in the" LOG.debug("Submitting message '%s' for execution in the"
" future to '%s'", ku.DelayedPretty(message), func_name) " future to '%s'", ku.DelayedPretty(message), func_name)
watch = tt.StopWatch() watch = timeutils.StopWatch()
watch.start() watch.start()
try: try:
self._executor.submit(_on_run, watch, content, message) self._executor.submit(_on_run, watch, content, message)

View File

@@ -22,6 +22,7 @@ import threading
from futurist import periodics from futurist import periodics
from oslo_utils import reflection from oslo_utils import reflection
from oslo_utils import timeutils
import six import six
from taskflow.engines.worker_based import dispatcher from taskflow.engines.worker_based import dispatcher
@@ -29,7 +30,6 @@ from taskflow.engines.worker_based import protocol as pr
from taskflow import logging from taskflow import logging
from taskflow.types import cache as base from taskflow.types import cache as base
from taskflow.types import notifier from taskflow.types import notifier
from taskflow.types import timing as tt
from taskflow.utils import kombu_utils as ku from taskflow.utils import kombu_utils as ku
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -123,7 +123,7 @@ class WorkerFinder(object):
""" """
if workers <= 0: if workers <= 0:
raise ValueError("Worker amount must be greater than zero") raise ValueError("Worker amount must be greater than zero")
watch = tt.StopWatch(duration=timeout) watch = timeutils.StopWatch(duration=timeout)
watch.start() watch.start()
with self._cond: with self._cond:
while self._total_workers() < workers: while self._total_workers() < workers:

View File

@@ -34,7 +34,6 @@ from taskflow import exceptions as exc
from taskflow.jobs import base from taskflow.jobs import base
from taskflow import logging from taskflow import logging
from taskflow import states from taskflow import states
from taskflow.types import timing
from taskflow.utils import misc from taskflow.utils import misc
from taskflow.utils import redis_utils as ru from taskflow.utils import redis_utils as ru
@@ -741,7 +740,7 @@ return cmsgpack.pack(result)
# up to the provided max-delay. In the future we could try having # up to the provided max-delay. In the future we could try having
# a secondary client connected into redis pubsub and use that # a secondary client connected into redis pubsub and use that
# instead, but for now this is simpler. # instead, but for now this is simpler.
w = timing.StopWatch(duration=timeout) w = timeutils.StopWatch(duration=timeout)
w.start() w.start()
delay = initial_delay delay = initial_delay
while True: while True:

View File

@@ -27,6 +27,7 @@ from kazoo.protocol import paths as k_paths
from kazoo.recipe import watchers from kazoo.recipe import watchers
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import timeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
import six import six
@@ -34,7 +35,6 @@ from taskflow import exceptions as excp
from taskflow.jobs import base from taskflow.jobs import base
from taskflow import logging from taskflow import logging
from taskflow import states from taskflow import states
from taskflow.types import timing as tt
from taskflow.utils import kazoo_utils from taskflow.utils import kazoo_utils
from taskflow.utils import misc from taskflow.utils import misc
@@ -672,7 +672,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
def wait(self, timeout=None): def wait(self, timeout=None):
# Wait until timeout expires (or forever) for jobs to appear. # Wait until timeout expires (or forever) for jobs to appear.
watch = tt.StopWatch(duration=timeout) watch = timeutils.StopWatch(duration=timeout)
watch.start() watch.start()
with self._job_cond: with self._job_cond:
while True: while True:

View File

@@ -20,12 +20,12 @@ import itertools
import time import time
from debtcollector import moves from debtcollector import moves
from oslo_utils import timeutils
from taskflow import exceptions as exc from taskflow import exceptions as exc
from taskflow.listeners import base from taskflow.listeners import base
from taskflow import logging from taskflow import logging
from taskflow import states from taskflow import states
from taskflow.types import timing as tt
STARTING_STATES = frozenset((states.RUNNING, states.REVERTING)) STARTING_STATES = frozenset((states.RUNNING, states.REVERTING))
FINISHED_STATES = frozenset((base.FINISH_STATES + (states.REVERTED,))) FINISHED_STATES = frozenset((base.FINISH_STATES + (states.REVERTED,)))
@@ -81,7 +81,7 @@ class DurationListener(base.Listener):
if state == states.PENDING: if state == states.PENDING:
self._timers.pop(task_name, None) self._timers.pop(task_name, None)
elif state in STARTING_STATES: elif state in STARTING_STATES:
self._timers[task_name] = tt.StopWatch().start() self._timers[task_name] = timeutils.StopWatch().start()
elif state in FINISHED_STATES: elif state in FINISHED_STATES:
timer = self._timers.pop(task_name, None) timer = self._timers.pop(task_name, None)
if timer is not None: if timer is not None:

View File

@@ -16,7 +16,7 @@
import threading import threading
from taskflow.types import timing as tt from oslo_utils import timeutils
class Latch(object): class Latch(object):
@@ -55,7 +55,7 @@ class Latch(object):
timeout expires otherwise false timeout expires otherwise false
:rtype: boolean :rtype: boolean
""" """
watch = tt.StopWatch(duration=timeout) watch = timeutils.StopWatch(duration=timeout)
watch.start() watch.start()
with self._cond: with self._cond:
while self._count > 0: while self._count > 0:

View File

@@ -16,13 +16,13 @@
import threading import threading
from debtcollector import moves
from oslo_utils import timeutils from oslo_utils import timeutils
#: Moved to oslo.utils (just reference them from there until a later time).
Split = timeutils.Split
#: Moved to oslo.utils (just reference them from there until a later time). # TODO(harlowja): Keep alias class... around until 2.0 is released.
StopWatch = timeutils.StopWatch StopWatch = moves.moved_class(timeutils.StopWatch, 'StopWatch', __name__,
version="1.15", removal_version="2.0")
class Timeout(object): class Timeout(object):

View File

@@ -20,13 +20,13 @@ import argparse
import cProfile as profiler import cProfile as profiler
import pstats import pstats
from oslo_utils import timeutils
import six import six
from six.moves import range as compat_range from six.moves import range as compat_range
from taskflow import engines from taskflow import engines
from taskflow.patterns import linear_flow as lf from taskflow.patterns import linear_flow as lf
from taskflow import task from taskflow import task
from taskflow.types import timing
def print_header(name): def print_header(name):
@@ -68,7 +68,7 @@ class ProfileIt(object):
class TimeIt(object): class TimeIt(object):
def __init__(self, name, args): def __init__(self, name, args):
self.watch = timing.StopWatch() self.watch = timeutils.StopWatch()
self.name = name self.name = name
self.args = args self.args = args