diff options
Diffstat (limited to 'buildstream/_scheduler/jobs/job.py')
-rw-r--r-- | buildstream/_scheduler/jobs/job.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/buildstream/_scheduler/jobs/job.py b/buildstream/_scheduler/jobs/job.py index 3ab7bfa3b..2b0809625 100644 --- a/buildstream/_scheduler/jobs/job.py +++ b/buildstream/_scheduler/jobs/job.py @@ -43,6 +43,22 @@ RC_PERM_FAIL = 2 RC_SKIPPED = 3 +# JobStatus: +# +# The job completion status, passed back through the +# complete callbacks. +# +class JobStatus(): + # Job succeeded + OK = 0 + + # A temporary BstError was raised + FAIL = 1 + + # A SkipJob was raised + SKIPPED = 3 + + # Used to distinguish between status messages and return values class Envelope(): def __init__(self, message_type, message): @@ -297,10 +313,10 @@ class Job(): # pass the result to the main thread. # # Args: - # success (bool): Whether the job was successful. + # status (JobStatus): The job exit status # result (any): The result returned by child_process(). # - def parent_complete(self, success, result): + def parent_complete(self, status, result): raise ImplError("Job '{kind}' does not implement parent_complete()" .format(kind=type(self).__name__)) @@ -571,9 +587,19 @@ class Job(): self.spawn() return - success = returncode in (RC_OK, RC_SKIPPED) - self.parent_complete(success, self._result) - self._scheduler.job_completed(self, success) + # Resolve the outward facing overall job completion status + # + if returncode == RC_OK: + status = JobStatus.OK + elif returncode == RC_SKIPPED: + status = JobStatus.SKIPPED + elif returncode in (RC_FAIL, RC_PERM_FAIL): + status = JobStatus.FAIL + else: + status = JobStatus.FAIL + + self.parent_complete(status, self._result) + self._scheduler.job_completed(self, status) # Force the deletion of the queue and process objects to try and clean up FDs self._queue = self._process = None |