Add WorkflowExecution.open to clarify code in some places
This commit is contained in:
parent
f38d23e483
commit
9c3996ff58
@ -243,7 +243,7 @@ class SWFBackend(BaseBackend):
|
||||
raise SWFValidationException("Invalid token")
|
||||
# decision task found, but WorflowExecution is CLOSED
|
||||
wfe = decision_task.workflow_execution
|
||||
if wfe.execution_status != "OPEN":
|
||||
if not wfe.open:
|
||||
raise SWFUnknownResourceFault(
|
||||
"execution",
|
||||
"WorkflowExecution=[workflowId={0}, runId={1}]".format(
|
||||
@ -331,7 +331,7 @@ class SWFBackend(BaseBackend):
|
||||
raise SWFValidationException("Invalid token")
|
||||
# activity task found, but WorflowExecution is CLOSED
|
||||
wfe = activity_task.workflow_execution
|
||||
if wfe.execution_status != "OPEN":
|
||||
if not wfe.open:
|
||||
raise SWFUnknownResourceFault(
|
||||
"execution",
|
||||
"WorkflowExecution=[workflowId={0}, runId={1}]".format(
|
||||
|
@ -83,7 +83,7 @@ class Domain(object):
|
||||
if w.workflow_id == workflow_id and w.run_id == run_id]
|
||||
else:
|
||||
_all = [w for w in self.workflow_executions
|
||||
if w.workflow_id == workflow_id and w.execution_status == "OPEN"]
|
||||
if w.workflow_id == workflow_id and w.open]
|
||||
# reduce
|
||||
wfe = _all[0] if _all else None
|
||||
# raise if closed / none
|
||||
|
@ -523,7 +523,7 @@ class WorkflowExecution(object):
|
||||
self.close_cause = "OPERATOR_INITIATED"
|
||||
|
||||
def has_timedout(self):
|
||||
if self.execution_status != "OPEN" or not self.start_timestamp:
|
||||
if not self.open or not self.start_timestamp:
|
||||
return False
|
||||
# TODO: handle the "NONE" case
|
||||
start_to_close_timeout = self.start_timestamp + \
|
||||
@ -535,3 +535,7 @@ class WorkflowExecution(object):
|
||||
self.execution_status = "CLOSED"
|
||||
self.close_status = "TIMED_OUT"
|
||||
self.timeout_type = "START_TO_CLOSE"
|
||||
|
||||
@property
|
||||
def open(self):
|
||||
return self.execution_status == "OPEN"
|
||||
|
Loading…
Reference in New Issue
Block a user