[CalendarServer-changes] [8762] CalendarServer/trunk/txdav/common/datastore/sql.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 23 19:03:52 PST 2012


Revision: 8762
          http://trac.macosforge.org/projects/calendarserver/changeset/8762
Author:   cdaboo at apple.com
Date:     2012-02-23 19:03:50 -0800 (Thu, 23 Feb 2012)
Log Message:
-----------
Fix stats printing.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/common/datastore/sql.py

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2012-02-23 19:55:36 UTC (rev 8761)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2012-02-24 03:03:50 UTC (rev 8762)
@@ -207,18 +207,14 @@
     def __init__(self):
         self.count = collections.defaultdict(int)
         self.times = collections.defaultdict(float)
-        self.tstamp = None
-        self.statement = None
     
     def startStatement(self, sql):
-        self.statement = sql
-        self.tstamp = time.time()
-        self.count[self.statement] += 1
+        self.count[sql] += 1
+        return sql, time.time()
 
-    def endStatement(self):
-        self.times[self.statement] += time.time() - self.tstamp
-        self.statement = None
-        self.tstamp = None
+    def endStatement(self, context):
+        sql, tstamp = context
+        self.times[sql] += time.time() - tstamp
         
     def printReport(self, toFile=sys.stdout):
         
@@ -614,7 +610,7 @@
         Execute some SQL (delegate to L{IAsyncTransaction}).
         """
         if self._stats:        
-            self._stats.startStatement(a[0])
+            statsContext = self._stats.startStatement(a[0])
         self.currentStatement = a[0]
         if self._store.logTransactionWaits and a[0].split(" ", 1)[0].lower() in ("insert", "update", "delete",):
             self.iudCount += 1
@@ -628,7 +624,7 @@
         finally:
             self.currentStatement = None
             if self._stats:        
-                self._stats.endStatement()
+                self._stats.endStatement(statsContext)
         returnValue(results)
 
     @inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120223/f34bdf0d/attachment.html>


More information about the calendarserver-changes mailing list