summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-06 14:21:00 -0500
committerAbderrahim Kitouni <a.kitouni@gmail.com>2019-04-12 14:58:11 +0000
commitc0888ad30f1edf6d5e3280140314c596dcf97482 (patch)
treedd8c0eaba97082f9317d223b39479982f8655f5b
parent5c36bca85bd8a3298c9df50c154a50f03507ab47 (diff)
downloadbuildstream-c0888ad30f1edf6d5e3280140314c596dcf97482.tar.gz
_scheduler/scheduler.py: Make _schedule_jobs() private
This is not used anywhere outside of the Scheduler, currently only the Scheduler itself is allowed to queue a job at this level. If the highlevel business logic for automatic queueing of auxiliary jobs moves to another location, we can make this public again.
-rw-r--r--buildstream/_scheduler/scheduler.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py
index 86a406430..2be6c3618 100644
--- a/buildstream/_scheduler/scheduler.py
+++ b/buildstream/_scheduler/scheduler.py
@@ -210,19 +210,6 @@ class Scheduler():
starttime = timenow
return timenow - starttime
- # schedule_jobs()
- #
- # Args:
- # jobs ([Job]): A list of jobs to schedule
- #
- # Schedule 'Job's for the scheduler to run. Jobs scheduled will be
- # run as soon any other queueing jobs finish, provided sufficient
- # resources are available for them to run
- #
- def schedule_jobs(self, jobs):
- for job in jobs:
- self.waiting_jobs.append(job)
-
# job_completed():
#
# Called when a Job completes
@@ -256,7 +243,7 @@ class Scheduler():
resources=[ResourceType.CACHE,
ResourceType.PROCESS],
complete_cb=self._run_cleanup)
- self.schedule_jobs([job])
+ self._schedule_jobs([job])
#######################################################
# Local Private Methods #
@@ -286,6 +273,21 @@ class Scheduler():
if not self.active_jobs and not self.waiting_jobs:
self.loop.stop()
+ # _schedule_jobs()
+ #
+ # The main entry point for jobs to be scheduled.
+ #
+ # This is called either as a result of scanning the queues
+ # in _schedule_queue_jobs(), or directly by the Scheduler
+ # to insert special jobs like cleanups.
+ #
+ # Args:
+ # jobs ([Job]): A list of jobs to schedule
+ #
+ def _schedule_jobs(self, jobs):
+ for job in jobs:
+ self.waiting_jobs.append(job)
+
# _schedule_queue_jobs()
#
# Ask the queues what jobs they want to schedule and schedule
@@ -330,7 +332,7 @@ class Scheduler():
# the next queue and process them.
process_queues = any(q.dequeue_ready() for q in self.queues)
- self.schedule_jobs(ready)
+ self._schedule_jobs(ready)
self._sched()
# _run_cleanup()
@@ -356,7 +358,7 @@ class Scheduler():
resources=[ResourceType.CACHE,
ResourceType.PROCESS],
exclusive_resources=[ResourceType.CACHE])
- self.schedule_jobs([job])
+ self._schedule_jobs([job])
# _suspend_jobs()
#