py_swf.clients.decision

class py_swf.clients.decision.DecisionClient(decision_config, boto_client)[source]

A client that provides a pythonic API for polling and responding to decision tasks through an SWF boto3 client.

Parameters:
  • decision_config (DecisionConfig) – Contains SWF values commonly used when making SWF api calls.
  • boto_client (Client) – A raw SWF boto3 client.
finish_decision_with_activity(task_token, activity_id, activity_name, activity_version, activity_input, schedule_to_close_timeout=None, schedule_to_start_timeout=None, start_to_close_timeout=None, heartbeat_timeout=None)[source]

Responds to a given decision task’s task_token to schedule an activity task to run.

Passthrough to respond_decision_task_completed().

Parameters:
  • task_token – The task_token returned from poll().
  • activity_id – A unique identifier for the activity task.
  • activity_name – Which activity name to execute.
  • activity_name – Version of the activity name.
  • activity_input – Freeform text of the input for the activity
  • schedule_to_close_timeout – Override default timeout for activity from schedule to finish

More info: http://docs.aws.amazon.com/amazonswf/latest/apireference/API_ScheduleActivityTaskDecisionAttributes.html :type identity: int :param schedule_to_start_timeout: Override default timeout for activity from schedule to start More info: http://docs.aws.amazon.com/amazonswf/latest/apireference/API_ScheduleActivityTaskDecisionAttributes.html :type identity: int :param start_to_close_timeout: Override default timeout for activity from start to finish More info: http://docs.aws.amazon.com/amazonswf/latest/apireference/API_ScheduleActivityTaskDecisionAttributes.html :type identity: int :return: None :rtype: NoneType

finish_workflow(task_token, result)[source]

Responds to a given decision task’s task_token to finish and terminate the workflow.

Passthrough to respond_decision_task_completed().

Parameters:
  • task_token – The task_token returned from poll().
  • result – Freeform text that represents the final result of the workflow.
Returns:

None

Return type:

NoneType

poll(identity=None, use_raw_event_history=False)[source]

Opens a connection to AWS and long-polls for decision tasks. When a decision is available, this function will return with exactly one decision task to execute. Only returns a contiguous subset of the most recent events. If you want to grab the entire history for a workflow, use walk_execution_history()

Passthrough to poll_for_decision_task().

Parameters:
  • identity (string) – A freeform text that identifies the client that performed the longpoll. Useful for debugging history.
  • use_raw_event_history (bool) – Whether to use the raw dictionary event history returned from AWS. Otherwise attempts to turn dictionaries into namedtuples recursively.
Returns:

A decision task to execute.

Return type:

DecisionTask

Raises:

py_swf.errors.NoTaskFound – Raised when polling for a decision task times out without receiving any tasks.

walk_execution_history(workflow_id, workflow_run_id, reverse_order=True, use_raw_event_history=False, maximum_page_size=1000)[source]

Lazily walks through the entire workflow history for a given workflow_id. This will make successive calls to SWF on demand when pagination is needed.

See get_workflow_execution_history() for more information.

Parameters:
  • workflow_id – The workflow_id returned from poll().
  • workflow_run_id – The workflow_run_id returned from poll().
  • reverse_order – Passthru for reverseOrder to get_workflow_execution_history()
  • use_raw_event_history (bool) – Whether to use the raw dictionary event history returned from AWS. Otherwise attempts to turn dictionaries into namedtuples recursively.
  • maximum_page_size – Passthru for maximumPageSize to get_workflow_execution_history()
Returns:

A generator that returns successive elements in the workflow execution history.

Return type:

collections.Iterable

class py_swf.clients.decision.DecisionTask(events, task_token, workflow_id, workflow_run_id, workflow_type)

Contains the metadata to execute a decision task.

See the response syntax in poll_for_decision_task().

events

Alias for field number 0

task_token

Alias for field number 1

workflow_id

Alias for field number 2

workflow_run_id

Alias for field number 3

workflow_type

Alias for field number 4