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
This commit is contained in:
Joshua Harlow
2014-05-09 11:05:29 -07:00
parent 258e009ae3
commit 449d221d82

View File

@@ -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')