summaryrefslogtreecommitdiffstats
path: root/src/python/openlmi/common/IndicationManager.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/openlmi/common/IndicationManager.py')
-rw-r--r--src/python/openlmi/common/IndicationManager.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/python/openlmi/common/IndicationManager.py b/src/python/openlmi/common/IndicationManager.py
index a17703f..f9a1655 100644
--- a/src/python/openlmi/common/IndicationManager.py
+++ b/src/python/openlmi/common/IndicationManager.py
@@ -253,6 +253,8 @@ class IndicationManager(singletonmixin.Singleton):
"""
SEVERITY_INFO = pywbem.Uint16(2) # CIM_Indication.PerceivedSeverity
+ COMMAND_STOP = 1 # Command to the IndicationManager thread to stop.
+
@cmpi_logging.trace_method
def __init__(self, env, nameprefix, namespace, ns_interop=None,
queue=None):
@@ -295,7 +297,7 @@ class IndicationManager(singletonmixin.Singleton):
new_broker = ch.PrepareAttachThread()
self._indication_sender = threading.Thread(
target=self._send_indications_loop, args=(new_broker,))
- self._indication_sender.daemon = True
+ self._indication_sender.daemon = False
self._indication_sender.start()
@property
@@ -714,7 +716,7 @@ class IndicationManager(singletonmixin.Singleton):
:param fltr_id: (``string``) ID of the filter to check.
"""
with self._access_lock:
- return ( class_name in self._filters
+ return (class_name in self._filters
and fltr_id in self._filters[class_name])
def _send_indications_loop(self, broker):
@@ -726,9 +728,31 @@ class IndicationManager(singletonmixin.Singleton):
"""
broker.AttachThread()
while True:
- indication = self._queue.get()
- cmpi_logging.logger.trace_info("Delivering indication %s" %
- (str(indication.path)))
- broker.DeliverIndication(self.namespace, indication)
+ command = self._queue.get()
+
+ if isinstance(command, pywbem.CIMInstance) :
+ indication = command
+ cmpi_logging.logger.trace_info("Delivering indication %s" %
+ (str(indication.path)))
+ broker.DeliverIndication(self.namespace, indication)
+
+ elif isinstance(command, int):
+ cmpi_logging.logger.trace_info("Received command %d", command)
+ if command == self.COMMAND_STOP:
+ if hasattr(self._queue, "task_done"):
+ self._queue.task_done()
+ break
+
if hasattr(self._queue, "task_done"):
self._queue.task_done()
+
+ cmpi_logging.logger.info("Stopped Indication thread.")
+
+ @cmpi_logging.trace_method
+ def shutdown(self):
+ """
+ Stop the thread. This method blocks until the thread is safely
+ destroyed.
+ """
+ self._queue.put(self.COMMAND_STOP)
+ self._indication_sender.join()