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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18412
Proposed branch: lp:~cjwatson/launchpad/twisted-job-runner-logging
Merge into: lp:launchpad
Diff against target: 36 lines (+6/-5)
1 file modified
lib/lp/services/job/runner.py (+6/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/twisted-job-runner-logging
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+325634@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/job/runner.py'
2--- lib/lp/services/job/runner.py 2016-05-06 09:28:28 +0000
3+++ lib/lp/services/job/runner.py 2017-06-14 12:00:34 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Facilities for running Jobs."""
10@@ -488,21 +488,22 @@
11 self.logger.info(
12 'Running %s.' % self.job_str(job))
13 self.logger.debug(
14- 'Running %r, lease expires %s', job, job.lease_expires)
15+ 'Running %s, lease expires %s',
16+ self.job_str(job), job.lease_expires)
17 deferred = self.pool.doWork(
18 RunJobCommand, job_id=job_id, _deadline=deadline)
19
20 def update(response):
21 if response is None:
22 self.incomplete_jobs.append(job)
23- self.logger.debug('No response for %r', job)
24+ self.logger.debug('No response for %s', self.job_str(job))
25 return
26 if response['success']:
27 self.completed_jobs.append(job)
28- self.logger.debug('Finished %r', job)
29+ self.logger.debug('Finished %s', self.job_str(job))
30 else:
31 self.incomplete_jobs.append(job)
32- self.logger.debug('Incomplete %r', job)
33+ self.logger.debug('Incomplete %s', self.job_str(job))
34 # Kill the worker that experienced a failure; this only
35 # works because there's a single worker.
36 self.pool.stopAWorker()