summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-07-10 16:21:09 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-07-10 16:24:58 +0900
commita5cacbe614b2cd8bd4b032d391850c41388029eb (patch)
tree0fdec7378a7f5b6a0c682f7f3b6d5e512d05c388
parentc96db03e291447f1f78c62e507326c22ec56960b (diff)
downloadbuildstream-a5cacbe614b2cd8bd4b032d391850c41388029eb.tar.gz
_scheduler/queue.py: Queue.done() return value now represents whether it was "skipped"
This is entirely for reporting purposes, so that operations which needed to be processed in order to determine if they were possible or not (like pulling an artifact which we dont know exists remotely yet), can display themselves as "skipped" in the case that nothing was done.
-rw-r--r--buildstream/_scheduler/queue.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/buildstream/_scheduler/queue.py b/buildstream/_scheduler/queue.py
index ce0a1e682..6f82d3266 100644
--- a/buildstream/_scheduler/queue.py
+++ b/buildstream/_scheduler/queue.py
@@ -125,6 +125,11 @@ class Queue():
# result (any): The return value of the process() implementation
# returncode (int): The process return code, 0 = success
#
+ # Returns:
+ # (bool): True if the element should appear to be skipped,
+ # this is useful in cases where we can only determine
+ # "skipped" status after processing.
+ #
def done(self, element, result, returncode):
pass
@@ -182,19 +187,26 @@ class Queue():
def job_done(self, job, returncode, element):
- if returncode == 0:
- self.done_queue.append(element)
- self.processed_elements.append(element)
- else:
- self.failed_elements.append(element)
-
# Shutdown the job
job.shutdown()
-
self.active_jobs.remove(job)
- # Give the result of the job to the Queue implementor
- self.done(element, job.result, returncode)
+ # Give the result of the job to the Queue implementor,
+ # and determine if it should be considered as processed
+ # or skipped.
+ if self.done(element, job.result, returncode):
+ skip = True
+ else:
+ skip = False
+
+ if returncode == 0:
+ self.done_queue.append(element)
+ if skip:
+ self.skipped_elements.append(element)
+ else:
+ self.processed_elements.append(element)
+ else:
+ self.failed_elements.append(element)
# Notify frontend
self.scheduler.job_completed(job, returncode == 0)