[CalendarServer-changes] [10250] CalendarServer/branches/users/glyph/queue-locking-and-timing
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 4 16:39:08 PST 2013
Revision: 10250
http://trac.calendarserver.org//changeset/10250
Author: glyph at apple.com
Date: 2013-01-04 16:39:08 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Make the tests pass.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/queue-locking-and-timing/
Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py 2013-01-05 00:39:07 UTC (rev 10249)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py 2013-01-05 00:39:08 UTC (rev 10250)
@@ -491,7 +491,7 @@
@inlineCallbacks
- def runHooks(self, ignored):
+ def runHooks(self, ignored=None):
"""
Callback for C{commit} and C{abort} Deferreds.
"""
@@ -516,10 +516,24 @@
# covered by txdav's test suite.
def __init__(self):
+ self._preCommit = _HookableOperation()
self._commit = _HookableOperation()
self._abort = _HookableOperation()
+ def _commitWithHooks(self, doCommit):
+ """
+ Run pre-hooks, commit, the real DB commit, and then post-hooks.
+ """
+ return self._preCommit.runHooks().addCallback(
+ lambda ignored: doCommit().addCallback(self._commit.runHooks)
+ )
+
+
+ def preCommit(self, operation):
+ return self._preCommit.addHook(operation)
+
+
def postCommit(self, operation):
return self._commit.addHook(operation)
@@ -648,9 +662,10 @@
# We're in the process of executing a block of commands. Wait until
# they're done. (Commit will be repeated in _checkNextBlock.)
return self._blockedQueue.commit()
- self._markComplete()
- return (super(_SingleTxn, self).commit()
- .addCallback(self._commit.runHooks))
+ def reallyCommit():
+ self._markComplete()
+ return super(_SingleTxn, self).commit()
+ return self._commitWithHooks(reallyCommit)
def abort(self):
@@ -1550,12 +1565,13 @@
def commit(self):
- self._committing = True
- def done(whatever):
- self._committed = True
- return whatever
- return (self._complete(Commit).addBoth(done)
- .addCallback(self._commit.runHooks))
+ def reallyCommit():
+ self._committing = True
+ def done(whatever):
+ self._committed = True
+ return whatever
+ return self._complete(Commit).addBoth(done)
+ return self._commitWithHooks(reallyCommit)
def abort(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/8ac6f86a/attachment.html>
More information about the calendarserver-changes
mailing list