[NEW PATCH] BZ#723579 AdvancedStatsThread should expose stop() (via gerrit-bot)
Federico Simoncelli
fsimonce at redhat.com
Wed Aug 3 15:08:01 UTC 2011
New patch submitted by Federico Simoncelli (fsimonce at redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/784
commit 3e5874b6d5171ac1480cf22133775c032bb28531
Author: Federico Simoncelli <fsimonce at redhat.com>
Date: Wed Aug 3 14:58:57 2011 +0000
BZ#723579 AdvancedStatsThread should expose stop()
The VmStatsThread wasn't exposing the stop method and therefore
it was never stopped during prepareForShutdown.
Even if it was declared as 'daemon' thread it kept the rest of
the application running satisfying its requests.
Change-Id: If8501b5286394e4e862e4bae965431cd395101fd
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 58a5604..077fc50 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -269,7 +269,7 @@ class AdvancedStatsFunction(object):
return bgn_sample, end_sample, (end_time - bgn_time)
-class AdvancedStatsThread(object):
+class AdvancedStatsThread(threading.Thread):
"""
A thread that runs the registered AdvancedStatsFunction objects
for statistic and monitoring purpose.
@@ -280,8 +280,8 @@ class AdvancedStatsThread(object):
"""
Initialize an AdvancedStatsThread object
"""
- self._thread = threading.Thread(target=self.run)
- self._thread.daemon = daemon
+ threading.Thread.__init__(self)
+ self.daemon = daemon
self._log = log
self._stopEvent = threading.Event()
@@ -294,7 +294,7 @@ class AdvancedStatsThread(object):
"""
Register the functions listed as arguments
"""
- if self._thread.isAlive():
+ if self.isAlive():
raise RuntimeError("AdvancedStatsThread is started")
for statsFunction in args:
@@ -305,7 +305,7 @@ class AdvancedStatsThread(object):
Start the execution of the thread and exit
"""
self._log.debug("Start statistics collection")
- self._thread.start()
+ threading.Thread.start(self)
def stop(self):
"""
More information about the vdsm-patches
mailing list