[CalendarServer-changes] [13554] twext/trunk/twext/enterprise/jobqueue.py

source_changes at macosforge.org source_changes at macosforge.org
Wed May 28 19:27:23 PDT 2014


Revision: 13554
          http://trac.calendarserver.org//changeset/13554
Author:   cdaboo at apple.com
Date:     2014-05-28 19:27:23 -0700 (Wed, 28 May 2014)
Log Message:
-----------
Fix logging.

Modified Paths:
--------------
    twext/trunk/twext/enterprise/jobqueue.py

Modified: twext/trunk/twext/enterprise/jobqueue.py
===================================================================
--- twext/trunk/twext/enterprise/jobqueue.py	2014-05-29 01:40:18 UTC (rev 13553)
+++ twext/trunk/twext/enterprise/jobqueue.py	2014-05-29 02:27:23 UTC (rev 13554)
@@ -373,23 +373,28 @@
         def _overtm(nb):
             return "{:.0f}".format(1000 * (t - astimestamp(nb)))
 
-        log.debug("JobItem: {jobid} starting to run".format(jobid=jobID))
+        log.debug("JobItem: {jobid} starting to run", jobid=jobID)
         txn = txnFactory(label="ultimatelyPerform: {}".format(jobID))
         try:
             job = yield cls.load(txn, jobID)
             if hasattr(txn, "_label"):
                 txn._label = "{} <{}>".format(txn._label, job.workType)
-            log.debug("JobItem: {jobid} loaded {work} t={tm}".format(
+            log.debug(
+                "JobItem: {jobid} loaded {work} t={tm}",
                 jobid=jobID,
                 work=job.workType,
-                tm=_tm())
+                tm=_tm(),
             )
             yield job.run()
 
         except NoSuchRecord:
             # The record has already been removed
             yield txn.commit()
-            log.debug("JobItem: {jobid} already removed t={tm}".format(jobid=jobID, tm=_tm()))
+            log.debug(
+                "JobItem: {jobid} already removed t={tm}",
+                jobid=jobID,
+                tm=_tm(),
+            )
 
         except JobFailedError:
             # Job failed: abort with cleanup, but pretend this method succeeded
@@ -397,35 +402,43 @@
                 @inlineCallbacks
                 def _cleanUp2(txn2):
                     job = yield cls.load(txn2, jobID)
-                    log.debug("JobItem: {jobid} marking as failed {count} t={tm}".format(jobid=jobID, count=job.failed + 1, tm=_tm()))
+                    log.debug(
+                        "JobItem: {jobid} marking as failed {count} t={tm}",
+                        jobid=jobID,
+                        count=job.failed + 1,
+                        tm=_tm(),
+                    )
                     yield job.failedToRun()
                 return inTransaction(txnFactory, _cleanUp2, "ultimatelyPerform._cleanUp")
             txn.postAbort(_cleanUp)
             yield txn.abort()
-            log.debug("JobItem: {jobid} failed {work} t={tm}".format(
+            log.debug(
+                "JobItem: {jobid} failed {work} t={tm}",
                 jobid=jobID,
                 work=job.workType,
-                tm=_tm()
-            ))
+                tm=_tm(),
+            )
 
         except:
             f = Failure()
-            log.error("JobItem: {jobid} unknown exception t={tm} {exc}".format(
+            log.error(
+                "JobItem: {jobid} unknown exception t={tm} {exc}",
                 jobid=jobID,
                 tm=_tm(),
                 exc=f,
-            ))
+            )
             yield txn.abort()
             returnValue(f)
 
         else:
             yield txn.commit()
-            log.debug("JobItem: {jobid} completed {work} t={tm} over={over}".format(
+            log.debug(
+                "JobItem: {jobid} completed {work} t={tm} over={over}",
                 jobid=jobID,
                 work=job.workType,
                 tm=_tm(),
-                over=_overtm(job.notBefore)
-            ))
+                over=_overtm(job.notBefore),
+            )
 
         returnValue(None)
 
@@ -519,11 +532,12 @@
                     yield workItem.doWork()
                     yield workItem.afterWork()
             except Exception as e:
-                log.error("JobItem: {jobid}, WorkItem: {workid} failed: {exc}".format(
+                log.error(
+                    "JobItem: {jobid}, WorkItem: {workid} failed: {exc}",
                     jobid=self.jobID,
                     workid=workItem.workID,
                     exc=e,
-                ))
+                )
                 raise JobFailedError(e)
 
         try:
@@ -826,11 +840,12 @@
             try:
                 yield NamedLock.acquire(self.transaction, self.group)
             except Exception as e:
-                log.error("JobItem: {jobid}, WorkItem: {workid} lock failed: {exc}".format(
+                log.error(
+                    "JobItem: {jobid}, WorkItem: {workid} lock failed: {exc}",
                     jobid=self.jobID,
                     workid=self.workID,
                     exc=e,
-                ))
+                )
                 raise JobFailedError(e)
 
         try:
@@ -1825,7 +1840,10 @@
             else:
                 minPriority = WORK_PRIORITY_LOW
             if self._lastMinPriority != minPriority:
-                log.debug("workCheck: jobqueue priority limit change: {}".format(minPriority))
+                log.debug(
+                    "workCheck: jobqueue priority limit change: {limit}",
+                    limit=minPriority,
+                )
             self._lastMinPriority = minPriority
 
             # Determine what the timestamp cutoff
@@ -1868,7 +1886,7 @@
                     log.error("Failed to perform job for jobid={jobid}, {exc}", jobid=nextJob.jobID, exc=e)
 
         if loopCounter:
-            log.debug("workCheck: processed {} jobs in one loop".format(loopCounter))
+            log.debug("workCheck: processed {ctr} jobs in one loop", ctr=loopCounter)
 
     _currentWorkDeferred = None
     _workCheckCall = None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140528/832f31ae/attachment-0001.html>


More information about the calendarserver-changes mailing list