Move some timeout conditionals to concerned models

This commit is contained in:
Jean-Baptiste Barth 2015-11-05 02:51:55 +01:00
commit 6027bf15c1
3 changed files with 8 additions and 4 deletions

View file

@ -24,6 +24,10 @@ class DecisionTask(object):
self.scheduled_at = datetime.now()
self.timeout_type = None
@property
def started(self):
return self.state == "STARTED"
def _check_workflow_execution_open(self):
if not self.workflow_execution.open:
raise SWFWorkflowExecutionClosedError()
@ -53,7 +57,7 @@ class DecisionTask(object):
self.state = "COMPLETED"
def first_timeout(self):
if self.state != "STARTED" or not self.workflow_execution.open:
if not self.started or not self.workflow_execution.open:
return None
# TODO: handle the "NONE" case
start_to_close_at = self.started_timestamp + int(self.start_to_close_timeout)