Skip to content

Commit

Permalink
Don't run a job if it depends on another one.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Dec 4, 2015
1 parent 660781d commit ec3f9f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python/saliweb/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,14 +984,17 @@ def _process_incoming_jobs(self):
# Save doing an extra SQL SELECT if we're already at the maximum
if numrunning >= maxrunning:
return
depends = self.db._get_job_dependencies()
for job in self.db._get_all_jobs_in_state('INCOMING',
order_by='submit_time'):
self._log("_process_incoming_jobs; trying to run job %s" % job.name)
job._try_run(self)
numrunning += 1
if numrunning >= maxrunning:
self._log("_process_incoming_jobs; job limit reached")
return
if job.name not in depends:
self._log("_process_incoming_jobs; trying to run job %s"
% job.name)
job._try_run(self)
numrunning += 1
if numrunning >= maxrunning:
self._log("_process_incoming_jobs; job limit reached")
return
self._log("_process_incoming_jobs done")

def _cleanup_incoming_jobs(self):
Expand Down
14 changes: 14 additions & 0 deletions test/backend/test_webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ def test_process_incoming(self):
ws2 = WebService(conf, db)
self.assertRaises(StateFileError, ws2._check_state_file)

def test_incoming_depends(self):
"""Check that incoming jobs honor dependencies"""
global job_log
job_log = []
db, conf, web = self._setup_webservice()
c = db.conn.cursor()
query = "INSERT INTO dependencies(child,parent) VALUES(?,?)"
c.execute(query, ('job1', 'job2'))
db.conn.commit()

web._process_incoming_jobs()
# job1 should not run because it depends on job2
self.assertEqual(job_log, [])

def test_max_running(self):
"""Make sure that limits.running is honored"""
global job_log
Expand Down

0 comments on commit ec3f9f2

Please sign in to comment.