Merge lp:~stevenk/lazr.jobrunner/only-run-if-canrun into lp:lazr.jobrunner

Proposed by Steve Kowalik
Status: Merged
Merged at revision: 50
Proposed branch: lp:~stevenk/lazr.jobrunner/only-run-if-canrun
Merge into: lp:lazr.jobrunner
Diff against target: 64 lines (+13/-2)
5 files modified
NEWS.txt (+5/-0)
setup.py (+1/-1)
src/lazr/jobrunner/celerytask.py (+2/-0)
src/lazr/jobrunner/tests/test_jobrunner.py (+4/-0)
src/lazr/jobrunner/version.txt (+1/-1)
To merge this branch: bzr merge lp:~stevenk/lazr.jobrunner/only-run-if-canrun
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+169105@code.launchpad.net

Description of the change

Only run the job if the job reports that it can run -- that will avoid us doing unnecessary work and then logging an OOPS when BranchScanJob attempt to transition from COMPLETED to RUNNING.

To post a comment you must log in.
51. By Steve Kowalik

Add canRun method

Revision history for this message
William Grant (wgrant) :
review: Approve (code)
52. By Steve Kowalik

Shift from a canRun method to a is_runnable property.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.txt'
2--- NEWS.txt 2012-10-25 14:03:11 +0000
3+++ NEWS.txt 2013-06-14 00:40:33 +0000
4@@ -1,7 +1,12 @@
5 News
6 ====
7
8+0.12
9+----
10+* Only run the job if its is_runnable property is True.
11+
12 0.11
13+----
14 * Add indirection to user error handling to avoid oopses if the Job is
15 security-proxied.
16
17
18=== modified file 'setup.py'
19--- setup.py 2012-10-25 14:03:11 +0000
20+++ setup.py 2013-06-14 00:40:33 +0000
21@@ -22,7 +22,7 @@
22 NEWS = open(os.path.join(here, 'NEWS.txt')).read()
23
24
25-version = '0.11'
26+version = '0.12'
27
28 install_requires = [
29 # List your project dependencies here.
30
31=== modified file 'src/lazr/jobrunner/celerytask.py'
32--- src/lazr/jobrunner/celerytask.py 2012-07-09 10:58:00 +0000
33+++ src/lazr/jobrunner/celerytask.py 2013-06-14 00:40:33 +0000
34@@ -41,6 +41,8 @@
35
36 def run(self, job_id):
37 job = self.job_source.get(job_id)
38+ if not job.is_runnable:
39+ return None
40 try:
41 job.acquireLease()
42 except LeaseHeld:
43
44=== modified file 'src/lazr/jobrunner/tests/test_jobrunner.py'
45--- src/lazr/jobrunner/tests/test_jobrunner.py 2012-10-24 17:57:42 +0000
46+++ src/lazr/jobrunner/tests/test_jobrunner.py 2013-06-14 00:40:33 +0000
47@@ -96,6 +96,10 @@
48 def getOopsVars(self):
49 return [('foo', 'bar')]
50
51+ @property
52+ def is_runnable(self):
53+ return True
54+
55
56 class VolatileAttributesJob:
57
58
59=== modified file 'src/lazr/jobrunner/version.txt'
60--- src/lazr/jobrunner/version.txt 2012-10-25 14:03:11 +0000
61+++ src/lazr/jobrunner/version.txt 2013-06-14 00:40:33 +0000
62@@ -1,1 +1,1 @@
63-0.11
64+0.12

Subscribers

People subscribed via source and target branches

to all changes: