[CalendarServer-changes] [13196] twext/trunk/twext/enterprise/jobqueue.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 8 09:28:26 PDT 2014
Revision: 13196
http://trac.calendarserver.org//changeset/13196
Author: cdaboo at apple.com
Date: 2014-04-08 09:28:26 -0700 (Tue, 08 Apr 2014)
Log Message:
-----------
Make sure all transactions have meaningful labels set.
Modified Paths:
--------------
twext/trunk/twext/enterprise/jobqueue.py
Modified: twext/trunk/twext/enterprise/jobqueue.py
===================================================================
--- twext/trunk/twext/enterprise/jobqueue.py 2014-04-08 16:25:37 UTC (rev 13195)
+++ twext/trunk/twext/enterprise/jobqueue.py 2014-04-08 16:28:26 UTC (rev 13196)
@@ -199,7 +199,7 @@
@inlineCallbacks
-def inTransaction(transactionCreator, operation):
+def inTransaction(transactionCreator, operation, label="jobqueue.inTransaction"):
"""
Perform the given operation in a transaction, committing or aborting as
required.
@@ -210,11 +210,13 @@
@param operation: a 1-arg callable that takes an L{IAsyncTransaction} and
returns a value.
+ @param label: label to be used with the transaction.
+
@return: a L{Deferred} that fires with C{operation}'s result or fails with
its error, unless there is an error creating, aborting or committing
the transaction.
"""
- txn = transactionCreator()
+ txn = transactionCreator(label=label)
try:
result = yield operation(txn)
except:
@@ -943,12 +945,13 @@
def runJob(txn):
try:
job = yield JobItem.load(txn, jobID)
+ txn._label = "{} <{}>".format(txn._label, job.workType)
yield job.run()
except NoSuchRecord:
# The record has already been removed
pass
- return inTransaction(txnFactory, runJob)
+ return inTransaction(txnFactory, runJob, label="ultimatelyPerform: {}".format(jobID))
@@ -1390,7 +1393,7 @@
except Exception as e:
log.err("Failed to perform periodic lost job for jobid={}, {}".format(overdueItem.jobID, e))
- return inTransaction(self.transactionFactory, workCheck)
+ return inTransaction(self.transactionFactory, workCheck, label="periodicLostWorkCheck")
_currentWorkDeferred = None
_lostWorkCheckCall = None
@@ -1455,7 +1458,7 @@
for node in nodes:
self._startConnectingTo(node)
- self._startingUp = inTransaction(self.transactionFactory, startup)
+ self._startingUp = inTransaction(self.transactionFactory, startup, label="PeerConnectionPool.startService")
@self._startingUp.addBoth
def done(result):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140408/17fe6917/attachment.html>
More information about the calendarserver-changes
mailing list