sfini.worker module

Activity task polling and execution.

You can provide you’re own workers: the interface to the activities is public. This module’s worker implementation uses threading, and is designed to be resource-managed outside of Python.

class sfini.worker.TaskExecution(activity, task_token: str, task_input: Union[None, bool, str, int, float, List[JSONable], Dict[str, JSONable]], *, session: sfini._util.AWSSession = None)[source]

Bases: object

Execute a task, providing heartbeats and catching failures.

Parameters:
  • activity (sfini.activity.CallableActivity) – activity to execute task of
  • task_token – task token for execution identification
  • task_input – task input
  • session – session to use for AWS communication
report_cancelled()[source]

Cancel a task execution: stop interaction with SFN.

run()[source]

Run task.

class sfini.worker.Worker(activity, name: str = None, *, session: sfini._util.AWSSession = None)[source]

Bases: object

Worker to poll for activity task executions.

Parameters:
  • activity (sfini.activity.CallableActivity) – activity to poll and run executions of
  • name – name of worker, used for identification, default: a combination of UUID and host’s FQDN
  • session – session to use for AWS communication
end()[source]

End polling.

join()[source]

Block until polling exit.

run()[source]

Run worker to poll for and execute specified tasks.

start()[source]

Start polling.

exception sfini.worker.WorkerCancel(*args, **kwargs)[source]

Bases: KeyboardInterrupt

Workflow execution interrupted by user.