← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/twisted-job-runner-logging into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/twisted-job-runner-logging into lp:launchpad.

Commit message:
Adjust logging of jobs in TwistedJobRunner.

With Python >= 2.7.7, we can't pass the job directly to `self.logger.debug`
because of https://github.com/zopefoundation/zope.security/issues/26.
However, using `self.job_str(job)` works around this and is more informative
anyway.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/twisted-job-runner-logging/+merge/325634
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/twisted-job-runner-logging into lp:launchpad.
=== modified file 'lib/lp/services/job/runner.py'
--- lib/lp/services/job/runner.py	2016-05-06 09:28:28 +0000
+++ lib/lp/services/job/runner.py	2017-06-14 12:00:34 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Facilities for running Jobs."""
@@ -488,21 +488,22 @@
         self.logger.info(
             'Running %s.' % self.job_str(job))
         self.logger.debug(
-            'Running %r, lease expires %s', job, job.lease_expires)
+            'Running %s, lease expires %s',
+            self.job_str(job), job.lease_expires)
         deferred = self.pool.doWork(
             RunJobCommand, job_id=job_id, _deadline=deadline)
 
         def update(response):
             if response is None:
                 self.incomplete_jobs.append(job)
-                self.logger.debug('No response for %r', job)
+                self.logger.debug('No response for %s', self.job_str(job))
                 return
             if response['success']:
                 self.completed_jobs.append(job)
-                self.logger.debug('Finished %r', job)
+                self.logger.debug('Finished %s', self.job_str(job))
             else:
                 self.incomplete_jobs.append(job)
-                self.logger.debug('Incomplete %r', job)
+                self.logger.debug('Incomplete %s', self.job_str(job))
                 # Kill the worker that experienced a failure; this only
                 # works because there's a single worker.
                 self.pool.stopAWorker()


Follow ups