From 4cb1d919dbf4b4d2dc534d7b1b4dccf694b54d38 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Mon, 28 Jul 2008 09:16:39 +0000 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9Ccanceled=E2=80=9D=20status=20for?= =?UTF-8?q?=20opcodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: ultrotter --- lib/constants.py | 1 + lib/jqueue.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/constants.py b/lib/constants.py index e85bd4868..8a56e07a9 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -266,6 +266,7 @@ JOB_STATUS_ERROR = "error" OP_STATUS_QUEUED = "queued" OP_STATUS_RUNNING = "running" +OP_STATUS_CANCELED = "canceled" OP_STATUS_SUCCESS = "success" OP_STATUS_ERROR = "error" diff --git a/lib/jqueue.py b/lib/jqueue.py index 46219c08b..fd8724107 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -161,13 +161,19 @@ class _QueuedJob(object): "run_op_index": self.run_op_index, } - def SetUnclean(self, msg): + def _SetStatus(self, status, msg): try: for op in self._ops: - op.SetStatus(constants.OP_STATUS_ERROR, msg) + op.SetStatus(status, msg) finally: self.storage.UpdateJob(self) + def SetUnclean(self, msg): + return self._SetStatus(constants.OP_STATUS_ERROR, msg) + + def SetCanceled(self, msg): + return self._SetStatus(constants.JOB_STATUS_CANCELED, msg) + def GetStatus(self): status = constants.JOB_STATUS_QUEUED @@ -187,6 +193,9 @@ class _QueuedJob(object): status = constants.JOB_STATUS_ERROR # The whole job fails if one opcode failed break + elif op_status == constants.OP_STATUS_CANCELED: + status = constants.OP_STATUS_CANCELED + break if all_success: status = constants.JOB_STATUS_SUCCESS -- GitLab