Python SDK for Absurd - PostgreSQL-based durable task execution
Project description
Absurd SDK for Python
Python SDK for Absurd: a PostgreSQL-based durable task execution system.
Absurd is the simplest durable execution workflow system you can think of. It's entirely based on Postgres and nothing else. It's almost as easy to use as a queue, but it handles scheduling and retries, and it does all of that without needing any other services to run in addition to Postgres.
What is Durable Execution?
Durable execution (or durable workflows) is a way to run long-lived, reliable functions that can survive crashes, restarts, and network failures without losing state or duplicating work. Instead of running your logic in memory, a durable execution system decomposes a task into smaller pieces (step functions) and records every step and decision.
Installation
pip install absurd-sdk
# or with uv
uv add absurd-sdk
Synchronous API
from absurd_sdk import Absurd
app = Absurd("postgresql://localhost/absurd")
@app.register_task(name="order-fulfillment")
def process_order(params, ctx):
payment = ctx.step("process-payment", lambda: stripe_charge(params["amount"]))
inventory = ctx.step("reserve-inventory", lambda: reserve_items(params["items"]))
shipment = ctx.await_event(f"shipment.packed:{params['order_id']}")
ctx.step("send-notification", lambda: send_email(params["email"], shipment))
return {"order_id": payment["id"], "tracking_number": shipment["tracking_number"]}
app.start_worker()
Asynchronous API
from absurd_sdk import AsyncAbsurd
app = AsyncAbsurd("postgresql://localhost/absurd")
@app.register_task(name="order-fulfillment")
async def process_order(params, ctx):
payment = await ctx.step("process-payment", lambda: stripe_charge_async(params["amount"]))
inventory = await ctx.step("reserve-inventory", lambda: reserve_items_async(params["items"]))
shipment = await ctx.await_event(f"shipment.packed:{params['order_id']}")
await ctx.step("send-notification", lambda: send_email_async(params["email"], shipment))
return {"order_id": payment["id"], "tracking_number": shipment["tracking_number"]}
await app.start_worker()
Using the run_step decorator
Because of limitations with lambda to be a single expression, for sync code
you can use the run_step decorator:
@app.register_task(name="my-task")
def my_task(params, ctx):
# Define and run a step in one go
@ctx.run_step()
def fetch_data():
return {"result": 42}
# fetch_data is now the return value ({"result": 42}), not a function
print(fetch_data) # {"result": 42}
The decorator is only implemented for synchronous tasks. In asynchronous tasks
use await ctx.step("step-name", lambda: ...) directly.
License and Links
- Issue Tracker
- License: Apache-2.0
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file absurd_sdk-0.0.1.tar.gz.
File metadata
- Download URL: absurd_sdk-0.0.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68f631b5526c5821d00e809c7496eff9e2369065e68df3b977ac00717cfd4d81
|
|
| MD5 |
c178117ca9f00ee8b325c0b4bff314a0
|
|
| BLAKE2b-256 |
868d8b58a21b6e3d9bab11438e3f849b24b55f1238e7e7678f5345bf3cddaaf6
|
Provenance
The following attestation bundles were made for absurd_sdk-0.0.1.tar.gz:
Publisher:
build.yml on earendil-works/absurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
absurd_sdk-0.0.1.tar.gz -
Subject digest:
68f631b5526c5821d00e809c7496eff9e2369065e68df3b977ac00717cfd4d81 - Sigstore transparency entry: 1186421266
- Sigstore integration time:
-
Permalink:
earendil-works/absurd@d8c83e82050f124395b0096cfee95407c6bd3138 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/earendil-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d8c83e82050f124395b0096cfee95407c6bd3138 -
Trigger Event:
push
-
Statement type:
File details
Details for the file absurd_sdk-0.0.1-py3-none-any.whl.
File metadata
- Download URL: absurd_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb8f5011a3c26a3a87ea7bf5181f2b99d0c1aa44638143ef10ce0c34eec26dd8
|
|
| MD5 |
653b08f5efbb66d8f8dd8f58b2b384b7
|
|
| BLAKE2b-256 |
cbe40448656f0254aea4e4ddb4f4e585a08da8dd19040816d394ca10d0f3dfa5
|
Provenance
The following attestation bundles were made for absurd_sdk-0.0.1-py3-none-any.whl:
Publisher:
build.yml on earendil-works/absurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
absurd_sdk-0.0.1-py3-none-any.whl -
Subject digest:
fb8f5011a3c26a3a87ea7bf5181f2b99d0c1aa44638143ef10ce0c34eec26dd8 - Sigstore transparency entry: 1186421272
- Sigstore integration time:
-
Permalink:
earendil-works/absurd@d8c83e82050f124395b0096cfee95407c6bd3138 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/earendil-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d8c83e82050f124395b0096cfee95407c6bd3138 -
Trigger Event:
push
-
Statement type: