Rename '_emit' -> '_try_emit' since it is best-effort (not ensured)
Change-Id: If45e46c35a17f9fd347c7a09ec7b7588c7a266e2
This commit is contained in:
@@ -285,16 +285,18 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
self._emit_notifications = bool(emit_notifications)
|
self._emit_notifications = bool(emit_notifications)
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
|
||||||
def _emit(self, state, details):
|
def _try_emit(self, state, details):
|
||||||
# Submit the work to the executor to avoid blocking the kazoo threads
|
# Submit the work to the executor to avoid blocking the kazoo threads
|
||||||
# and queue(s)...
|
# and queue(s)...
|
||||||
worker = self._worker
|
worker = self._worker
|
||||||
if worker is None:
|
if worker is None or not self._emit_notifications:
|
||||||
|
# Worker has been destroyed or we aren't supposed to emit anything
|
||||||
|
# in the first place...
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
worker.submit(self.notifier.notify, state, details)
|
worker.submit(self.notifier.notify, state, details)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
# Notification thread is shutdown just skip submitting a
|
# Notification thread is/was shutdown just skip submitting a
|
||||||
# notification...
|
# notification...
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -353,7 +355,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
job = self._known_jobs.pop(path, None)
|
job = self._known_jobs.pop(path, None)
|
||||||
if job is not None:
|
if job is not None:
|
||||||
LOG.debug("Removed job that was at path '%s'", path)
|
LOG.debug("Removed job that was at path '%s'", path)
|
||||||
self._emit(base.REMOVAL, details={'job': job})
|
self._try_emit(base.REMOVAL, details={'job': job})
|
||||||
|
|
||||||
def _process_child(self, path, request):
|
def _process_child(self, path, request):
|
||||||
"""Receives the result of a child data fetch request."""
|
"""Receives the result of a child data fetch request."""
|
||||||
@@ -393,7 +395,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
self._known_jobs[path] = job
|
self._known_jobs[path] = job
|
||||||
self._job_cond.notify_all()
|
self._job_cond.notify_all()
|
||||||
if job is not None:
|
if job is not None:
|
||||||
self._emit(base.POSTED, details={'job': job})
|
self._try_emit(base.POSTED, details={'job': job})
|
||||||
|
|
||||||
def _on_job_posting(self, children, delayed=True):
|
def _on_job_posting(self, children, delayed=True):
|
||||||
LOG.debug("Got children %s under path %s", children, self.path)
|
LOG.debug("Got children %s under path %s", children, self.path)
|
||||||
@@ -464,7 +466,7 @@ class ZookeeperJobBoard(base.NotifyingJobBoard):
|
|||||||
with self._job_cond:
|
with self._job_cond:
|
||||||
self._known_jobs[job_path] = job
|
self._known_jobs[job_path] = job
|
||||||
self._job_cond.notify_all()
|
self._job_cond.notify_all()
|
||||||
self._emit(base.POSTED, details={'job': job})
|
self._try_emit(base.POSTED, details={'job': job})
|
||||||
return job
|
return job
|
||||||
|
|
||||||
@base.check_who
|
@base.check_who
|
||||||
|
Reference in New Issue
Block a user