From 89c6c7435b33c6989607d077f66c0aac9ff4500d Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 9 Jul 2014 18:56:55 -0700 Subject: [PATCH] Avoid naming time type module the same as a builtin In order to avoid naming conflicts which can easily occur if we name our time module as a python builtin just pick a name that doesn't conflict (it still retains the same meaning). Change-Id: Ia19f3776689d2b1f31f7cbfaa15e53f99a3ee900 --- taskflow/conductors/single_threaded.py | 2 +- taskflow/engines/worker_based/executor.py | 2 +- taskflow/engines/worker_based/protocol.py | 4 ++-- taskflow/jobs/backends/impl_zookeeper.py | 4 ++-- taskflow/listeners/timing.py | 4 ++-- taskflow/tests/unit/test_types.py | 2 +- taskflow/types/latch.py | 2 +- taskflow/types/{time.py => timing.py} | 0 8 files changed, 10 insertions(+), 10 deletions(-) rename taskflow/types/{time.py => timing.py} (100%) diff --git a/taskflow/conductors/single_threaded.py b/taskflow/conductors/single_threaded.py index d13d666c..25bd53a0 100644 --- a/taskflow/conductors/single_threaded.py +++ b/taskflow/conductors/single_threaded.py @@ -20,7 +20,7 @@ import six from taskflow.conductors import base from taskflow import exceptions as excp from taskflow.listeners import logging as logging_listener -from taskflow.types import time as tt +from taskflow.types import timing as tt from taskflow.utils import lock_utils LOG = logging.getLogger(__name__) diff --git a/taskflow/engines/worker_based/executor.py b/taskflow/engines/worker_based/executor.py index 2b82f01a..f5afc72e 100644 --- a/taskflow/engines/worker_based/executor.py +++ b/taskflow/engines/worker_based/executor.py @@ -23,7 +23,7 @@ from taskflow.engines.worker_based import cache from taskflow.engines.worker_based import protocol as pr from taskflow.engines.worker_based import proxy from taskflow import exceptions as exc -from taskflow.types import time as tt +from taskflow.types import timing as tt from taskflow.utils import async_utils from taskflow.utils import misc from taskflow.utils import reflection diff --git a/taskflow/engines/worker_based/protocol.py b/taskflow/engines/worker_based/protocol.py index db693ecc..ea994272 100644 --- a/taskflow/engines/worker_based/protocol.py +++ b/taskflow/engines/worker_based/protocol.py @@ -23,7 +23,7 @@ import six from taskflow.engines.action_engine import executor from taskflow import exceptions as excp -from taskflow.types import time +from taskflow.types import timing as tt from taskflow.utils import misc from taskflow.utils import reflection @@ -194,7 +194,7 @@ class Request(Message): self._arguments = arguments self._progress_callback = progress_callback self._kwargs = kwargs - self._watch = time.StopWatch(duration=timeout).start() + self._watch = tt.StopWatch(duration=timeout).start() self._state = WAITING self.result = futures.Future() diff --git a/taskflow/jobs/backends/impl_zookeeper.py b/taskflow/jobs/backends/impl_zookeeper.py index be305a12..88f068f7 100644 --- a/taskflow/jobs/backends/impl_zookeeper.py +++ b/taskflow/jobs/backends/impl_zookeeper.py @@ -33,7 +33,7 @@ from taskflow.openstack.common import excutils from taskflow.openstack.common import jsonutils from taskflow.openstack.common import uuidutils from taskflow import states -from taskflow.types import time +from taskflow.types import timing as tt from taskflow.utils import kazoo_utils from taskflow.utils import lock_utils from taskflow.utils import misc @@ -587,7 +587,7 @@ class ZookeeperJobBoard(jobboard.NotifyingJobBoard): # Wait until timeout expires (or forever) for jobs to appear. watch = None if timeout is not None: - watch = time.StopWatch(duration=float(timeout)).start() + watch = tt.StopWatch(duration=float(timeout)).start() self._job_cond.acquire() try: while True: diff --git a/taskflow/listeners/timing.py b/taskflow/listeners/timing.py index 87240a36..e21dd642 100644 --- a/taskflow/listeners/timing.py +++ b/taskflow/listeners/timing.py @@ -21,7 +21,7 @@ import logging from taskflow import exceptions as exc from taskflow.listeners import base from taskflow import states -from taskflow.types import time +from taskflow.types import timing as tt STARTING_STATES = (states.RUNNING, states.REVERTING) FINISHED_STATES = base.FINISH_STATES + (states.REVERTED,) @@ -64,7 +64,7 @@ class TimingListener(base.ListenerBase): if state == states.PENDING: self._timers.pop(task_name, None) elif state in STARTING_STATES: - self._timers[task_name] = time.StopWatch().start() + self._timers[task_name] = tt.StopWatch().start() elif state in FINISHED_STATES: if task_name in self._timers: self._record_ending(self._timers[task_name], task_name) diff --git a/taskflow/tests/unit/test_types.py b/taskflow/tests/unit/test_types.py index e69cac0d..e17a9fe2 100644 --- a/taskflow/tests/unit/test_types.py +++ b/taskflow/tests/unit/test_types.py @@ -20,7 +20,7 @@ import networkx as nx from taskflow import test from taskflow.types import graph -from taskflow.types import time as tt +from taskflow.types import timing as tt from taskflow.types import tree diff --git a/taskflow/types/latch.py b/taskflow/types/latch.py index 4451fc32..9aa2622d 100644 --- a/taskflow/types/latch.py +++ b/taskflow/types/latch.py @@ -16,7 +16,7 @@ import threading -from taskflow.types import time as tt +from taskflow.types import timing as tt class Latch(object): diff --git a/taskflow/types/time.py b/taskflow/types/timing.py similarity index 100% rename from taskflow/types/time.py rename to taskflow/types/timing.py