Commit 4cb1d919 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add “canceled” status for opcodes

Reviewed-by: ultrotter
parent 17621a25
......@@ -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"
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment