[CalendarServer-changes] [11736] CalendarServer/trunk/twext/enterprise

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 18 12:09:09 PDT 2013


Revision: 11736
          http://trac.calendarserver.org//changeset/11736
Author:   glyph at apple.com
Date:     2013-09-18 12:09:09 -0700 (Wed, 18 Sep 2013)
Log Message:
-----------
Address a slightly different form of the same leak.

Modified Paths:
--------------
    CalendarServer/trunk/twext/enterprise/adbapi2.py
    CalendarServer/trunk/twext/enterprise/test/test_adbapi2.py

Modified: CalendarServer/trunk/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/trunk/twext/enterprise/adbapi2.py	2013-09-18 00:07:03 UTC (rev 11735)
+++ CalendarServer/trunk/twext/enterprise/adbapi2.py	2013-09-18 19:09:09 UTC (rev 11736)
@@ -536,6 +536,7 @@
         """
         pre = self._preCommit.runHooks()
         def ok(ignored):
+            self._abort.clear()
             return doCommit().addCallback(self._commit.runHooks)
         def failed(why):
             return self.abort().addCallback(lambda ignored: why)

Modified: CalendarServer/trunk/twext/enterprise/test/test_adbapi2.py
===================================================================
--- CalendarServer/trunk/twext/enterprise/test/test_adbapi2.py	2013-09-18 00:07:03 UTC (rev 11735)
+++ CalendarServer/trunk/twext/enterprise/test/test_adbapi2.py	2013-09-18 19:09:09 UTC (rev 11736)
@@ -508,7 +508,7 @@
         self.assertEquals(conns[0]._commitCount, 0)
 
 
-    def circularReferenceTest(self, finish):
+    def circularReferenceTest(self, finish, hook):
         """
         Collecting a completed (committed or aborted) L{IAsyncTransaction}
         should not leak any circular references.
@@ -523,7 +523,7 @@
                 """
                 commitExecuted.append(True)
                 return t.execSQL("teardown", [])
-            t.preCommit(holdAReference)
+            hook(t, holdAReference)
             finish(t)
         self.failIf(commitExecuted, "Commit hook executed.")
         carefullyManagedScope()
@@ -534,16 +534,34 @@
         """
         Committing a transaction does not cause gc garbage.
         """
-        self.circularReferenceTest(lambda txn: txn.commit())
+        self.circularReferenceTest(lambda txn: txn.commit(),
+                                   lambda txn, hook: txn.preCommit(hook))
 
 
+    def test_noGarbageOnCommitWithAbortHook(self):
+        """
+        Committing a transaction does not cause gc garbage.
+        """
+        self.circularReferenceTest(lambda txn: txn.commit(),
+                                   lambda txn, hook: txn.postAbort(hook))
+
+
     def test_noGarbageOnAbort(self):
         """
         Aborting a transaction does not cause gc garbage.
         """
-        self.circularReferenceTest(lambda txn: txn.abort())
+        self.circularReferenceTest(lambda txn: txn.abort(),
+                                   lambda txn, hook: txn.preCommit(hook))
 
 
+    def test_noGarbageOnAbortWithPostCommitHook(self):
+        """
+        Aborting a transaction does not cause gc garbage.
+        """
+        self.circularReferenceTest(lambda txn: txn.abort(),
+                                   lambda txn, hook: txn.postCommit(hook))
+
+
     def test_tooManyConnectionsWhileOthersFinish(self):
         """
         L{ConnectionPool.connection} will not spawn more than the maximum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130918/78fe5d87/attachment.html>


More information about the calendarserver-changes mailing list