Fix heartbeatTimeout of NONE and polling responses when there are no tasks (#3680)

* fix heartbeatTimeout of NONE resulting in ValueError and polling returning empty string taskToken when it shouldn't be returned

* fix expected taskToken in impacted tests

Co-authored-by: Clint Parham <cparham@aligntech.com>
This commit is contained in:
redparham 2021-02-12 08:01:42 -05:00 committed by GitHub
commit b60de10c79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 13 deletions

View file

@ -73,7 +73,10 @@ class ActivityTask(BaseModel):
def first_timeout(self):
if not self.open or not self.workflow_execution.open:
return None
# TODO: handle the "NONE" case
if self.timeouts["heartbeatTimeout"] == "NONE":
return None
heartbeat_timeout_at = self.last_heartbeat_timestamp + int(
self.timeouts["heartbeatTimeout"]
)

View file

@ -446,9 +446,7 @@ class SWFResponse(BaseResponse):
if decision:
return json.dumps(decision.to_full_dict(reverse_order=reverse_order))
else:
return json.dumps(
{"previousStartedEventId": 0, "startedEventId": 0, "taskToken": ""}
)
return json.dumps({"previousStartedEventId": 0, "startedEventId": 0})
def count_pending_decision_tasks(self):
domain_name = self._params["domain"]
@ -482,7 +480,7 @@ class SWFResponse(BaseResponse):
if activity_task:
return json.dumps(activity_task.to_full_dict())
else:
return json.dumps({"startedEventId": 0, "taskToken": ""})
return json.dumps({"startedEventId": 0})
def count_pending_activity_tasks(self):
domain_name = self._params["domain"]