Skip to content

Conversation

timl3136
Copy link
Member

What changed?
Add base and decision task handler

Why?
We need task handler to handle polled tasks

How did you test it?
unit test

Potential risks

Release notes

Documentation Changes

Signed-off-by: Tim Li <[email protected]>
Comment on lines 14 to 15
force_create_new_decision_task: bool = False
query_results: Optional[dict] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed at the moment. This is related to local activities and workflow query. We might have better solutions later than copying java legacy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those fields are used in RespondDecisionTaskCompletedRequest but we can remove them for now

workflow_type = task.workflow_type

if not workflow_execution or not workflow_type:
logger.error("Decision task missing workflow execution or type")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log task?

cause = DecisionTaskFailedCause.DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES

# Create error details
error_message = str(error).encode('utf-8')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a TODO here. I think we need a data converter for this.


logger.info("Decision task failure response sent")

except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just don't handle exception at all and let worker to handle it

Comment on lines 147 to 148
return_new_decision_task=decision_result.force_create_new_decision_task,
force_create_new_decision_task=decision_result.force_create_new_decision_task
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these are for locally dispatched activities. We can add it later so it's cleaner. Same thing for query related logic

logger.exception("Error responding to decision task completion")
raise

def cleanup_workflow_engine(self, workflow_id: str, run_id: str) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not used anywhere


# Get or create workflow engine for this workflow execution
engine_key = f"{workflow_id}:{run_id}"
if engine_key not in self._workflow_engines:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't support sticky cache yet. This will cause memory leak without exit logic. Maybe just remove _workflow_engines for now and add it when sticky cache is implemented.

Signed-off-by: Tim Li <[email protected]>
Signed-off-by: Tim Li <[email protected]>
Copy link
Member

@shijiesheng shijiesheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timl3136 timl3136 merged commit 2c1e5ca into cadence-workflow:main Sep 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants