Ensure we are really setup before being connected
Change-Id: I42d9beeca159913a0eed5f9867c8ac0b191ffc3e
This commit is contained in:
@@ -351,6 +351,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
self._job_base = k_paths.join(path, JOB_PREFIX)
|
self._job_base = k_paths.join(path, JOB_PREFIX)
|
||||||
self._worker = None
|
self._worker = None
|
||||||
self._emit_notifications = bool(emit_notifications)
|
self._emit_notifications = bool(emit_notifications)
|
||||||
|
self._connected = False
|
||||||
|
|
||||||
def _emit(self, state, details):
|
def _emit(self, state, details):
|
||||||
# Submit the work to the executor to avoid blocking the kazoo queue.
|
# Submit the work to the executor to avoid blocking the kazoo queue.
|
||||||
@@ -715,7 +716,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def connected(self):
|
def connected(self):
|
||||||
return self._client.connected
|
return self._connected and self._client.connected
|
||||||
|
|
||||||
@lock_utils.locked(lock='_open_close_lock')
|
@lock_utils.locked(lock='_open_close_lock')
|
||||||
def close(self):
|
def close(self):
|
||||||
@@ -729,6 +730,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
with self._job_cond:
|
with self._job_cond:
|
||||||
self._known_jobs.clear()
|
self._known_jobs.clear()
|
||||||
LOG.debug("Stopped & cleared local state")
|
LOG.debug("Stopped & cleared local state")
|
||||||
|
self._connected = False
|
||||||
|
|
||||||
@lock_utils.locked(lock='_open_close_lock')
|
@lock_utils.locked(lock='_open_close_lock')
|
||||||
def connect(self, timeout=10.0):
|
def connect(self, timeout=10.0):
|
||||||
@@ -763,6 +765,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
self.path,
|
self.path,
|
||||||
func=self._on_job_posting,
|
func=self._on_job_posting,
|
||||||
allow_session_lost=True)
|
allow_session_lost=True)
|
||||||
|
self._connected = True
|
||||||
except excp.IncompatibleVersion:
|
except excp.IncompatibleVersion:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
try_clean()
|
try_clean()
|
||||||
|
|||||||
Reference in New Issue
Block a user