summaryrefslogtreecommitdiff
path: root/buildstream/_scheduler/queues/buildqueue.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildstream/_scheduler/queues/buildqueue.py')
-rw-r--r--buildstream/_scheduler/queues/buildqueue.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/buildstream/_scheduler/queues/buildqueue.py b/buildstream/_scheduler/queues/buildqueue.py
index e867ef010..2a07fdd6c 100644
--- a/buildstream/_scheduler/queues/buildqueue.py
+++ b/buildstream/_scheduler/queues/buildqueue.py
@@ -31,8 +31,7 @@ class BuildQueue(Queue):
resources = [ResourceType.PROCESS, ResourceType.CACHE]
def process(self, element):
- element._assemble()
- return element._get_unique_id()
+ return element._assemble()
def status(self, element):
# state of dependencies may have changed, recalculate element state
@@ -51,18 +50,20 @@ class BuildQueue(Queue):
return QueueStatus.READY
- def _check_cache_size(self, job, element):
- if not job.child_data:
- return
+ def _check_cache_size(self, job, element, artifact_size):
- artifact_size = job.child_data.get('artifact_size', False)
+ # After completing a build job, add the artifact size
+ # as returned from Element._assemble() to the estimated
+ # artifact cache size
+ #
+ cache = element._get_artifact_cache()
+ cache.add_artifact_size(artifact_size)
- if artifact_size:
- cache = element._get_artifact_cache()
- cache.add_artifact_size(artifact_size)
-
- if cache.get_approximate_cache_size() > cache.cache_quota:
- self._scheduler.check_cache_size()
+ # If the estimated size outgrows the quota, ask the scheduler
+ # to queue a job to actually check the real cache size.
+ #
+ if cache.get_approximate_cache_size() > cache.cache_quota:
+ self._scheduler.check_cache_size()
def done(self, job, element, result, success):
@@ -70,8 +71,8 @@ class BuildQueue(Queue):
# Inform element in main process that assembly is done
element._assemble_done()
- # This has to be done after _assemble_done, such that the
- # element may register its cache key as required
- self._check_cache_size(job, element)
+ # This has to be done after _assemble_done, such that the
+ # element may register its cache key as required
+ self._check_cache_size(job, element, result)
return True