summaryrefslogtreecommitdiff
path: root/distbuild
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-23 14:51:10 (GMT)
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-04-23 14:51:10 (GMT)
commitc00c828938918701dd7c3566c765c3a9e10b2253 (patch)
tree857074433687eb50865138b72b59673994918b55 /distbuild
parentaad372d64d3e4a09bfaf0c54616ce482019f9ba2 (diff)
downloadmorph-c00c828938918701dd7c3566c765c3a9e10b2253.tar.gz
Add Jobs and Job classes
Diffstat (limited to 'distbuild')
-rw-r--r--distbuild/worker_build_scheduler.py59
1 files changed, 49 insertions, 10 deletions
diff --git a/distbuild/worker_build_scheduler.py b/distbuild/worker_build_scheduler.py
index ebbefd0..de8c95b 100644
--- a/distbuild/worker_build_scheduler.py
+++ b/distbuild/worker_build_scheduler.py
@@ -91,21 +91,60 @@ class _NeedJob(object):
class _HaveAJob(object):
- def __init__(self, artifact, initiator_id):
+ def __init__(self, job):
+ self.job = job
+
+class Job(object):
+
+ def __init__(self, job_id, artifact, initiator_id):
+ self.id = job_id
self.artifact = artifact
- self.initiator_id = initiator_id
-
-
-class _JobIsFinished(object):
+ self.initiators = [initiator_id]
+ self.who = None # we don't know who's going to do this yet
+ self.is_building = False
- def __init__(self, msg):
- self.msg = msg
-
+ def add_initiator(self, initiator_id):
+ self.initiators.append(initiator_id)
+
+class Jobs(object):
+
+ def __init__(self, idgen):
+ self._idgen = idgen
+ self._jobs = {}
+
+ def get(self, artifact_basename):
+ return (self._jobs[artifact_basename]
+ if artifact_basename in self._jobs else None)
+
+ def create(self, artifact, initiator_id):
+ job = Job(self._idgen.next(), artifact, initiator_id)
+ self._jobs[job.artifact.basename()] = job
+ return job
+
+ def remove(self, job):
+ del self._jobs[job.artifact.basename()]
+
+ def exists(self, artifact_basename):
+ return artifact_basename in self._jobs
+
+ def get_next_job(self):
+ # for now just return the first thing we find that's not being built
+ waiting = [job for (_, job) in
+ self._jobs.iteritems() if job.who == None]
+
+ return waiting.pop() if len(waiting) > 0 else None
+
+ def __repr__(self):
+ return str([job.artifact.basename()
+ for (_, job) in self._jobs.iteritems()])
-class _JobFailed(object):
+class _BuildFinished(object):
+
+ pass
+
+class _BuildFailed(object):
pass
-
class _Cached(object):