Activity worker for performing AWS StepFunctions tasks
Project description
StepFunctions Activity Worker
A worker that listens to a StepFunctions activity and executes a provided function using the inputs from the activity task.
The StepFunctions Activity Worker encapsulates all the parts of communicating with the StepFunctions API so you don't have to worry about task heartbeats or maintaining task tokens and success/failure scenarios; all you have to worry about is executing the task.
Installation
Install from PyPI:
pip install stepfunctions_activity_worker
Usage
from stepfunctions_activity_worker import ActivityWorker
def my_task(**task_input):
"""Perform the task based on this task's input."""
# Perform your task here!
return {"result": "done!"}
if __name__ == "__main__":
activity_arn = "PLACE YOUR ACTIVITY ARN HERE"
worker = ActiityWorker(activity_arn, my_task)
worker.listen()
Warning
The ActivityWorker
class, if not provided with a client
argument on instantiation, will create a properly configured client from your default session.
However, if you are providing an already instantiated client
to the ActivityWorker
class, make sure it is proply configured to make StepFunctions API calls!
The GetActivityTask
API call blocks for 60 seconds which matches the botocore.config.Config
default read_timeout
. This means that if the API response for GetActivityTask
is not punctual (which it often isn't) it will cause unnecessary retry-requests & eventually bubble up an HTTP exception.
import boto3
import botocore
from stepfunctions_activity_worker import ActivityWorker
config = botocore.config.Config(
read_timeout=70,
# Insert other custom configuration here
)
stepfunctions = boto3.client('stepfunctions', config=config)
activity_worker = ActivityWorker(my_function, client=stepfunctions)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for stepfunctions_activity_worker-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c59009fcee430d9ee2532675e13f182144076608a21c922abfe07c81e6c573ba |
|
MD5 | 8382a4de1345e16feaec0d0981e48288 |
|
BLAKE2b-256 | ba40697105782654047f7ce6d1af439cd3de7b490d955dda37728aa0cc6d10b8 |
Hashes for stepfunctions_activity_worker-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de8454f37a3ac289bae9f08a9d857ffb2741d3bd1454bd062ad88a95ff6c0588 |
|
MD5 | 4c062d6449973e2a96ebb7842a69537a |
|
BLAKE2b-256 | d68cbc4a2432f345950cd97cd99af5accfedb3d266385c0f5b1f69f551feda29 |