Tasks

SWF activity task management.

Cancelled

Current activity task has been cancelled.

PartialTaskConfiguration

Partial activity task configuration.

TaskConfiguration

Activity task configuration.

WorkerTask

Activity worker activity task.

cancel_task

Cancel the current activity task.

complete_task

Complete the current activity task.

fail_task

Fail the current activity task.

get_number_of_pending_tasks

Get the number of pending activity tasks.

request_task

Request (poll for) an activity task; blocks until task is received.

send_heartbeat

Send a heartbeat to SWF for the current activity task.

exception swf_typed.Cancelled[source]

Current activity task has been cancelled.

class swf_typed.PartialTaskConfiguration(task_list: str = None, runtime_timeout: timedelta | None = _Sentinel(), schedule_timeout: timedelta | None = _Sentinel(), total_timeout: timedelta | None = _Sentinel(), heartbeat_timeout: timedelta | None = _Sentinel(), priority: int = None)[source]

Partial activity task configuration.

classmethod from_api(data) PartialTaskConfiguration[source]

Deserialise from SWF API response data.

get_api_args()[source]

Serialise to SWF API request arguments.

heartbeat_timeout: timedelta | None = _Sentinel()

Heartbeat timeout.

priority: int = None

Task priority.

runtime_timeout: timedelta | None = _Sentinel()

Finish timeout.

schedule_timeout: timedelta | None = _Sentinel()

Start timeout.

task_list: str = None

Task task-list.

total_timeout: timedelta | None = _Sentinel()

Total finish timeout.

class swf_typed.TaskConfiguration(task_list: str, runtime_timeout: timedelta | None, schedule_timeout: timedelta | None, total_timeout: timedelta | None, heartbeat_timeout: timedelta | None = _Sentinel(), priority: int = None)[source]

Activity task configuration.

classmethod from_api(data) TaskConfiguration[source]

Deserialise from SWF API response data.

heartbeat_timeout: timedelta | None = _Sentinel()

Heartbeat timeout.

priority: int = None

Task priority.

runtime_timeout: timedelta | None

Finish timeout.

schedule_timeout: timedelta | None

Start timeout.

task_list: str

Task task-list.

total_timeout: timedelta | None

Total finish timeout.

class swf_typed.WorkerTask(token: str, id: str, activity: _activities.ActivityId, execution: _executions.ExecutionId, task_started_execution_history_event_id: int, input: str = None)[source]

Activity worker activity task.

activity: _activities.ActivityId

Task activity.

execution: _executions.ExecutionId

Task execution.

classmethod from_api(data) WorkerTask[source]

Deserialise from SWF API response data.

id: str

Task ID.

input: str = None

Task input.

task_started_execution_history_event_id: int

History event ID for task start.

token: str

Task token, provided by SWF.

swf_typed.cancel_task(token: str, details: str = None, client: botocore.client.BaseClient = None) None[source]

Cancel the current activity task.

Only valid if the activity task is open and has a cancellation request.

Parameters:
  • token – activity task token

  • details – extra information, usually for explanation

  • client – SWF client

swf_typed.complete_task(token: str, result: str = None, client: botocore.client.BaseClient = None) None[source]

Complete the current activity task.

Only valid if the activity task is open.

Parameters:
  • token – activity task token

  • result – task result

  • client – SWF client

swf_typed.fail_task(token: str, reason: str = None, details: str = None, client: botocore.client.BaseClient = None) None[source]

Fail the current activity task.

Only valid if the activity task is open.

Parameters:
  • token – activity task token

  • reason – failure reason, usually for classification

  • details – failure details, usually for explanation

  • client – SWF client

swf_typed.get_number_of_pending_tasks(task_list: str, domain: str, client: botocore.client.BaseClient = None) int[source]

Get the number of pending activity tasks.

Warns if the number of pending tasks is greater than what’s returned.

Parameters:
  • task_list – activity task-list

  • domain – domain of task-list

  • client – SWF client

Returns:

number of pending tasks

swf_typed.request_task(task_list: str, domain: str, worker_identity: str = None, no_tasks_callback: Callable[[], None] = None, client: botocore.client.BaseClient = None) WorkerTask[source]

Request (poll for) an activity task; blocks until task is received.

Parameters:
  • task_list – activity task-list to request from

  • domain – domain of task-list

  • worker_identity – activity worker identity, recorded in execution history

  • no_tasks_callback – called after no tasks were provided by SWF

  • client – SWF client

Returns:

activity task

swf_typed.send_heartbeat(token: str, details: str = None, client: botocore.client.BaseClient = None) None[source]

Send a heartbeat to SWF for the current activity task.

Parameters:
  • token – activity task token

  • details – activity task progress message

  • client – SWF client

Raises:

Cancelled – if activity task was cancelled by decider