[CalendarServer-changes] [10848] CalendarServer/branches/users/sagen/testing/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 5 11:44:04 PST 2013
Revision: 10848
http://trac.calendarserver.org//changeset/10848
Author: sagen at apple.com
Date: 2013-03-05 11:44:04 -0800 (Tue, 05 Mar 2013)
Log Message:
-----------
Handle the case where someone else has already deleted duplicate work items
Modified Paths:
--------------
CalendarServer/branches/users/sagen/testing/twext/enterprise/dal/record.py
CalendarServer/branches/users/sagen/testing/twext/enterprise/queue.py
Modified: CalendarServer/branches/users/sagen/testing/twext/enterprise/dal/record.py
===================================================================
--- CalendarServer/branches/users/sagen/testing/twext/enterprise/dal/record.py 2013-03-05 18:52:12 UTC (rev 10847)
+++ CalendarServer/branches/users/sagen/testing/twext/enterprise/dal/record.py 2013-03-05 19:44:04 UTC (rev 10848)
@@ -190,9 +190,12 @@
@classmethod
@inlineCallbacks
def load(cls, transaction, *primaryKey):
- self = (yield cls.query(transaction,
- cls._primaryKeyComparison(primaryKey)))[0]
- returnValue(self)
+ results = (yield cls.query(transaction,
+ cls._primaryKeyComparison(primaryKey)))
+ if len(results) != 1:
+ returnValue(None)
+ else:
+ returnValue(results[0])
@classmethod
Modified: CalendarServer/branches/users/sagen/testing/twext/enterprise/queue.py
===================================================================
--- CalendarServer/branches/users/sagen/testing/twext/enterprise/queue.py 2013-03-05 18:52:12 UTC (rev 10847)
+++ CalendarServer/branches/users/sagen/testing/twext/enterprise/queue.py 2013-03-05 19:44:04 UTC (rev 10848)
@@ -827,14 +827,15 @@
def work(txn):
workItemClass = WorkItem.forTable(table)
workItem = yield workItemClass.load(txn, workID)
- if workItem.group is not None:
- yield NamedLock.acquire(txn, workItem.group)
- # TODO: what if we fail? error-handling should be recorded someplace,
- # the row should probably be marked, re-tries should be triggerable
- # administratively.
- yield workItem.delete()
- # TODO: verify that workID is the primary key someplace.
- yield workItem.doWork()
+ if workItem is not None:
+ if workItem.group is not None:
+ yield NamedLock.acquire(txn, workItem.group)
+ # TODO: what if we fail? error-handling should be recorded someplace,
+ # the row should probably be marked, re-tries should be triggerable
+ # administratively.
+ yield workItem.delete()
+ # TODO: verify that workID is the primary key someplace.
+ yield workItem.doWork()
return inTransaction(txnFactory, work)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130305/20a064ec/attachment.html>
More information about the calendarserver-changes
mailing list