summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-10-03 18:13:51 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-10-03 18:33:39 +0900
commit11320fe278a536f525edc825f1b6fed5c5c9770e (patch)
tree8c8c3d3c709a39b305363f03a09b5223d347392f
parentc943761632c94274d3662b215b25ded0eeefc6fc (diff)
downloadbuildstream-11320fe278a536f525edc825f1b6fed5c5c9770e.tar.gz
_scheduler: Fix bookkeeping of terminated jobs
* Enhanced the base Job class to bookkeep which jobs have been terminated, and to consider them as `skipped` when asked via the `skipped` property. * Enhanced the base Queue class to bookkeep the job statuses more carefully. This fixes #479
-rw-r--r--buildstream/_scheduler/jobs/job.py14
-rw-r--r--buildstream/_scheduler/queues/queue.py18
2 files changed, 22 insertions, 10 deletions
diff --git a/buildstream/_scheduler/jobs/job.py b/buildstream/_scheduler/jobs/job.py
index 1c6b4a582..a1b90a080 100644
--- a/buildstream/_scheduler/jobs/job.py
+++ b/buildstream/_scheduler/jobs/job.py
@@ -119,6 +119,8 @@ class Job():
self._result = None # Return value of child action in the parent
self._tries = 0 # Try count, for retryable jobs
self._skipped_flag = False # Indicate whether the job was skipped.
+ self._terminated = False # Whether this job has been explicitly terminated
+
# If False, a retry will not be attempted regardless of whether _tries is less than _max_retries.
#
self._retry_flag = True
@@ -190,6 +192,8 @@ class Job():
# Terminate the process using multiprocessing API pathway
self._process.terminate()
+ self._terminated = True
+
# terminate_wait()
#
# Wait for terminated jobs to complete
@@ -273,18 +277,22 @@ class Job():
# running the integration commands).
#
# Args:
- # (int): The plugin identifier for this task
+ # task_id (int): The plugin identifier for this task
#
def set_task_id(self, task_id):
self._task_id = task_id
# skipped
#
+ # This will evaluate to True if the job was skipped
+ # during processing, or if it was forcefully terminated.
+ #
# Returns:
- # bool: True if the job was skipped while processing.
+ # (bool): Whether the job should appear as skipped
+ #
@property
def skipped(self):
- return self._skipped_flag
+ return self._skipped_flag or self._terminated
#######################################################
# Abstract Methods #
diff --git a/buildstream/_scheduler/queues/queue.py b/buildstream/_scheduler/queues/queue.py
index f058663a1..0e07a078f 100644
--- a/buildstream/_scheduler/queues/queue.py
+++ b/buildstream/_scheduler/queues/queue.py
@@ -326,16 +326,20 @@ class Queue():
detail=traceback.format_exc())
self.failed_elements.append(element)
else:
-
- # No exception occured, handle the success/failure state in the normal way
#
+ # No exception occured in post processing
+ #
+
+ # All jobs get placed on the done queue for later processing.
self._done_queue.append(job)
- if success:
- if not job.skipped:
- self.processed_elements.append(element)
- else:
- self.skipped_elements.append(element)
+ # A Job can be skipped whether or not it has failed,
+ # we want to only bookkeep them as processed or failed
+ # if they are not skipped.
+ if job.skipped:
+ self.skipped_elements.append(element)
+ elif success:
+ self.processed_elements.append(element)
else:
self.failed_elements.append(element)