[rhmessaging-commits] rhmessaging commits: r3991 - mgmt/newdata/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed May 26 11:01:14 EDT 2010


Author: justi9
Date: 2010-05-26 11:01:14 -0400 (Wed, 26 May 2010)
New Revision: 3991

Modified:
   mgmt/newdata/mint/python/mint/session.py
   mgmt/newdata/mint/python/mint/update.py
   mgmt/newdata/mint/python/mint/util.py
Log:
Handle objectProps calls with no properties set; add a class for profiling threads

Modified: mgmt/newdata/mint/python/mint/session.py
===================================================================
--- mgmt/newdata/mint/python/mint/session.py	2010-05-25 19:54:21 UTC (rev 3990)
+++ mgmt/newdata/mint/python/mint/session.py	2010-05-26 15:01:14 UTC (rev 3991)
@@ -101,23 +101,33 @@
         # because I don't get any agent info; instead
 
     def objectProps(self, broker, obj):
-        agent = self.model.get_agent(obj._agent)
+        agent = self.model.get_agent(obj.getAgent())
 
-        if self.model.app.update_thread.isAlive():
-            if obj.getTimestamps()[2]:
-                up = ObjectDelete(self.model, agent, obj)
-            else:
-                up = ObjectUpdate(self.model, agent, obj)
+        if not self.model.app.update_thread.isAlive():
+            return
 
-            self.model.app.update_thread.enqueue(up)
+        # XXX objectProps is getting called even if no properties are
+        # set
 
+        if not obj.getProperties():
+            return
+
+        if obj.getTimestamps()[2]:
+            up = ObjectDelete(self.model, agent, obj)
+        else:
+            up = ObjectUpdate(self.model, agent, obj)
+
+        self.model.app.update_thread.enqueue(up)
+
     def objectStats(self, broker, obj):
-        agent = self.model.get_agent(obj._agent)
+        agent = self.model.get_agent(obj.getAgent())
 
-        if self.model.app.update_thread.isAlive():
-            up = ObjectAddSample(self.model, agent, obj)
-            self.model.app.update_thread.enqueue(up)
+        if not self.model.app.update_thread.isAlive():
+            return
 
+        up = ObjectAddSample(self.model, agent, obj)
+        self.model.app.update_thread.enqueue(up)
+
     def event(self, broker, event):
         """ Invoked when an event is raised. """
         pass

Modified: mgmt/newdata/mint/python/mint/update.py
===================================================================
--- mgmt/newdata/mint/python/mint/update.py	2010-05-25 19:54:21 UTC (rev 3990)
+++ mgmt/newdata/mint/python/mint/update.py	2010-05-26 15:01:14 UTC (rev 3991)
@@ -408,8 +408,6 @@
         self.agent = agent
 
     def do_process(self, conn, stats):
-        print "Ahoy!"
-        
         cursor = conn.cursor()
 
         id = self.agent.id
@@ -419,7 +417,6 @@
                 for cls in pkg._classes:
                     for obj in cls.get_selection(cursor, _qmf_agent_id=id):
                         obj.delete(cursor)
-                        print "Bam!", obj
         finally:
             cursor.close()
 

Modified: mgmt/newdata/mint/python/mint/util.py
===================================================================
--- mgmt/newdata/mint/python/mint/util.py	2010-05-25 19:54:21 UTC (rev 3990)
+++ mgmt/newdata/mint/python/mint/util.py	2010-05-26 15:01:14 UTC (rev 3991)
@@ -10,6 +10,7 @@
 from getpass import getpass
 from qmf.console import ObjectId
 from random import sample
+from tempfile import mkstemp
 from threading import Thread, Lock, RLock
 from time import clock, sleep
 from traceback import print_exc
@@ -180,3 +181,43 @@
 
 def ess(num, ending="s"):
     return num != 1 and ending or ""
+
+class ProfilerThread(object):
+    def calibrate(self, prof):
+        print "Calibrating"
+        
+        biases = list()
+    
+        for i in range(3):
+            bias = prof.calibrate(50000)
+            biases.append(bias)
+            print i, bias
+        
+        prof.bias = sum(biases) / float(3)
+
+        print "Using bias %f" % prof.bias
+
+    def run(self):
+        from cProfile import Profile
+        from pstats import Stats
+
+        prof = Profile()
+
+        if hasattr(prof, "calibrate"):
+            self.calibrate(prof)
+
+        prof.runctx("self.do_run()",
+                    globals=globals(),
+                    locals=locals())
+
+        fd, path = mkstemp(".profile")
+
+        prof.dump_stats(path)
+
+        stats = Stats(path)
+
+        stats.sort_stats("cumulative").print_stats(15)
+        stats.sort_stats("time").print_stats(15)
+
+    def do_run(self):
+        raise Exception("Not implemented")



More information about the rhmessaging-commits mailing list