Simplify decision task handling in SWF backend

This commit is contained in:
Jean-Baptiste Barth 2015-10-26 18:06:04 +01:00
parent a0e484fa6d
commit d650f71d9c
2 changed files with 9 additions and 16 deletions

View File

@ -180,16 +180,16 @@ class SWFBackend(BaseBackend):
# aren't distributed.
#
# TODO: handle long polling (case 2) for decision tasks
decision_candidates = []
for _, wfe in domain.workflow_executions.iteritems():
if wfe.task_list == task_list:
decision_candidates += wfe.scheduled_decision_tasks
if any(decision_candidates):
candidates = []
for _task_list, tasks in domain.decision_task_lists.iteritems():
if _task_list == task_list:
candidates += filter(lambda t: t.state == "SCHEDULED", tasks)
if any(candidates):
# TODO: handle task priorities (but not supported by boto for now)
decision = min(decision_candidates, key=lambda d: d.scheduled_at)
wfe = decision.workflow_execution
wfe.start_decision_task(decision.task_token, identity=identity)
return decision
task = min(candidates, key=lambda d: d.scheduled_at)
wfe = task.workflow_execution
wfe.start_decision_task(task.task_token, identity=identity)
return task
else:
return None

View File

@ -182,13 +182,6 @@ class WorkflowExecution(object):
self.domain.decision_tasks
)
@property
def scheduled_decision_tasks(self):
return filter(
lambda t: t.state == "SCHEDULED",
self.decision_tasks
)
@property
def activity_tasks(self):
return filter(