[CalendarServer-changes] [10245] CalendarServer/branches/users/glyph/queue-locking-and-timing
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 4 16:39:02 PST 2013
Revision: 10245
http://trac.calendarserver.org//changeset/10245
Author: glyph at apple.com
Date: 2013-01-04 16:39:02 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Transplant locking classes to their own isolated area.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py
CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.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:01 UTC (rev 10244)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/locking.py 2013-01-05 00:39:02 UTC (rev 10245)
@@ -18,3 +18,56 @@
"""
Utilities to restrict concurrency based on mutual exclusion.
"""
+
+from twext.enterprise.dal.model import Table
+from twext.enterprise.dal.model import SQLType
+from twext.enterprise.dal.model import Constraint
+from twext.enterprise.dal.syntax import SchemaSyntax
+from twext.enterprise.dal.model import Schema
+
+
+def makeLockSchema(inSchema):
+ """
+ Create a self-contained schema just for L{Locker} use, in C{inSchema}.
+
+ @param inSchema: a L{Schema} to add the locks table to.
+ @type inSchema: L{Schema}
+
+ @return: inSchema
+ """
+ LockTable = Table(inSchema, 'NAMED_LOCKS')
+
+ LockTable.addColumn("LOCK_NAME", SQLType("varchar", 255))
+ LockTable.tableConstraint(Constraint.NOT_NULL, ["LOCK_NAME"])
+ LockTable.tableConstraint(Constraint.UNIQUE, ["LOCK_NAME"])
+ LockTable.primaryKey = [LockTable.columnNamed("LOCK_NAME")]
+
+ return inSchema
+
+LockSchema = SchemaSyntax(makeLockSchema(Schema(__file__)))
+
+
+
+class Locker(object):
+ """
+ Acquire named locks against a database.
+ """
+
+ def lock(self, name, wait=False):
+ """
+ Acquire a lock with the given name.
+
+ @param name: The name of the lock to acquire. Against the same store,
+ no two locks may be acquired.
+ @type name: L{unicode}
+
+ @param wait: Whether or not to wait for the lock. If L{True}, the
+ L{Deferred} returned by L{lock} make some time to fire; if
+ L{False}, it should quickly fail instead.
+
+ @return: a L{Deferred} that fires with an L{AcquiredLock} when the lock
+ has fired, or fails when the lock has not been acquired.
+ """
+ raise NotImplementedError()
+
+
Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py 2013-01-05 00:39:01 UTC (rev 10244)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py 2013-01-05 00:39:02 UTC (rev 10245)
@@ -162,28 +162,6 @@
-def makeLockSchema(inSchema):
- """
- Create a self-contained schema just for L{Locker} use, in C{inSchema}.
-
- @param inSchema: a L{Schema} to add the locks table to.
- @type inSchema: L{Schema}
-
- @return: inSchema
- """
- LockTable = Table(inSchema, 'NAMED_LOCKS')
-
- LockTable.addColumn("LOCK_NAME", SQLType("varchar", 255))
- LockTable.tableConstraint(Constraint.NOT_NULL, ["LOCK_NAME"])
- LockTable.tableConstraint(Constraint.UNIQUE, ["LOCK_NAME"])
- LockTable.primaryKey = [LockTable.columnNamed("LOCK_NAME")]
-
- return inSchema
-
-LockSchema = SchemaSyntax(makeLockSchema(Schema(__file__)))
-
-
-
@inlineCallbacks
def inTransaction(transactionCreator, operation):
"""
@@ -438,30 +416,6 @@
-class Locker(object):
- """
- Acquire named locks against a database.
- """
-
- def lock(self, name, wait=False):
- """
- Acquire a lock with the given name.
-
- @param name: The name of the lock to acquire. Against the same store,
- no two locks may be acquired.
- @type name: L{unicode}
-
- @param wait: Whether or not to wait for the lock. If L{True}, the
- L{Deferred} returned by L{lock} make some time to fire; if
- L{False}, it should quickly fail instead.
-
- @return: a L{Deferred} that fires with an L{AcquiredLock} when the lock
- has fired, or fails when the lock has not been acquired.
- """
- raise NotImplementedError()
-
-
-
class PerformWork(Command):
"""
Notify another process that it must do some work that has been persisted to
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/2279d877/attachment.html>
More information about the calendarserver-changes
mailing list