From 449d221d822d2d68a32b81700d798a5fb6aa0584 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 9 May 2014 11:05:29 -0700 Subject: [PATCH] Remove the _clear method and do not reset the job_watcher The _clear method is only used in one place (in close) so the benefit of it being a function is not really valueable so move its logic to the close method itself. Also fix that the job_watcher does not need to be reset since it can now survive session lose/disconnection, setting it to none is not useful anymore and actually creates more watchers that provide the same data (which is bad). Change-Id: I243ec0551a341df74f478b0161ffd559a75278fe --- taskflow/jobs/backends/impl_zookeeper.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/taskflow/jobs/backends/impl_zookeeper.py b/taskflow/jobs/backends/impl_zookeeper.py index 8fa0c484..4de2091d 100644 --- a/taskflow/jobs/backends/impl_zookeeper.py +++ b/taskflow/jobs/backends/impl_zookeeper.py @@ -571,11 +571,6 @@ class ZookeeperJobBoard(jobboard.NotifyingJobBoard): def _state_change_listener(self, state): LOG.debug("Kazoo client has changed to state: %s", state) - def _clear(self): - with self._job_lock: - self._known_jobs.clear() - self._job_watcher = None - def wait(self, timeout=None): # Wait until timeout expires (or forever) for jobs to appear. watch = None @@ -620,7 +615,8 @@ class ZookeeperJobBoard(jobboard.NotifyingJobBoard): LOG.debug("Shutting down the notifier") self._worker.shutdown() self._worker = None - self._clear() + with self._job_lock: + self._known_jobs.clear() LOG.debug("Stopped & cleared local state") @lock_utils.locked(lock='_open_close_lock')