[CalendarServer-changes] [10258] CalendarServer/branches/users/glyph/queue-locking-and-timing

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 4 16:39:20 PST 2013


Revision: 10258
          http://trac.calendarserver.org//changeset/10258
Author:   glyph at apple.com
Date:     2013-01-04 16:39:20 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Automatically release the lock upon commit.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/

Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py	2013-01-05 00:39:18 UTC (rev 10257)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py	2013-01-05 00:39:20 UTC (rev 10258)
@@ -80,7 +80,10 @@
         @return: a L{Deferred} that fires with an L{AcquiredLock} when the lock
             has fired, or fails when the lock has not been acquired.
         """
-        return cls.create(txn, lockName=name)
+        def autoRelease(self):
+            txn.preCommit(lambda: self.release(True))
+            return self
+        return cls.create(txn, lockName=name).addCallback(autoRelease)
 
 
     def release(self, ignoreAlreadyUnlocked=False):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/f929ead4/attachment.html>


More information about the calendarserver-changes mailing list