Fix openDecisionTasks counter not updated when we complete a DecisionTask
This commit is contained in:
parent
918cf8a4e3
commit
49e44c8ee6
@ -279,10 +279,10 @@ class WorkflowExecution(object):
|
||||
Handles a Decision according to SWF docs.
|
||||
See: http://docs.aws.amazon.com/amazonswf/latest/apireference/API_Decision.html
|
||||
"""
|
||||
# 'decisions' can be None per boto.swf defaults, so better exiting
|
||||
# directly for falsy values
|
||||
# 'decisions' can be None per boto.swf defaults, so replace it with something iterable
|
||||
if not decisions:
|
||||
return
|
||||
decisions = []
|
||||
|
||||
# handle each decision separately, in order
|
||||
for decision in decisions:
|
||||
decision_type = decision["decisionType"]
|
||||
@ -306,6 +306,9 @@ class WorkflowExecution(object):
|
||||
# TODO: implement Decision type: StartTimer
|
||||
raise NotImplementedError("Cannot handle decision: {}".format(decision_type))
|
||||
|
||||
# finally decrement counter if and only if everything went well
|
||||
self.open_counts["openDecisionTasks"] -= 1
|
||||
|
||||
def complete(self, event_id, result=None):
|
||||
self.execution_status = "CLOSED"
|
||||
self.close_status = "COMPLETED"
|
||||
|
@ -76,6 +76,15 @@ def test_count_pending_decision_tasks_on_non_existent_task_list():
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "non-existent")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
@mock_swf
|
||||
def test_count_pending_decision_tasks_after_decision_completes():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed(resp["taskToken"])
|
||||
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "queue")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
# RespondDecisionTaskCompleted endpoint
|
||||
@mock_swf
|
||||
|
Loading…
Reference in New Issue
Block a user