ChopFlow Python Client
A Python worker + producer SDK for ChopFlow, the distributed task
queue in Rust. The broker and all execution logic live in Rust; this SDK lets you
define and run task handlers in Python and enqueue tasks from Python, speaking
gRPC to the broker over the contract in proto/proto/chopflow.proto.
Build status: Verified —
pytestpasses (Python 3.12 + grpcio 1.83) and the examples round-trip end-to-end against the Rust broker (Python producer enqueues an echo task → Python worker acks →AsyncResult.get()returnsCOMPLETED).
Requirements
- Python 3.10+
- The Rust broker binary (
chopflow_broker) running somewhere reachable. Build it withcargo build -p chopflow_brokerfrom the repo root.
Install
The SDK is not yet published to PyPI; install it editable from source:
cd clients/python
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
The generated gRPC stubs (src/chopflow/_generated/) are committed, so no protoc
toolchain is required to install or use the SDK. Regenerate them only when the proto
changes:
python generate.py # reads ../../proto/proto/chopflow.proto
Usage
Worker — define and run handlers in Python
from chopflow import ChopFlowWorker, task
@task("resize_image")
def resize(payload):
# ...your logic; return something JSON-serializable...
return {"status": "ok", "resized": payload}
worker = (
ChopFlowWorker.builder()
.broker("localhost:8000")
.tags("image")
.resources("cpu", 2)
.build()
)
# `resize_image` was registered via the @task decorator above.
worker.register("ping", lambda p: {"pong": True}) # or register callables directly
worker.start_and_await() # blocks until Ctrl+C
The worker registers with the broker, sends heartbeats, polls FetchTasks, executes
the matching handler, and acknowledges each task. A handler that raises is acked as a
failure and the broker applies its retry/dead-letter policy. Tasks with no registered
handler fall back to the worker's default handler (override via
worker.register_default(...)).
Producer — enqueue tasks and await results
from chopflow import ChopFlowClient
with ChopFlowClient.connect("localhost:8000") as client:
result = (
client.enqueue("resize_image")
.payload({"path": "/img/a.png", "w": 128})
.tags("image")
.max_retries(2)
.priority(5) # higher = claimed before lower (default 0)
.enqueue()
)
task = result.get(timeout=60) # blocks until terminal
print(task.status_name, task.result)
AsyncResult.get() polls GetTaskStatus until the task reaches a terminal state
(COMPLETED, FAILED, DEADLETTERED, CANCELLED). By default it raises
TaskFailedError if the task did not complete; pass raise_on_failure=False to get
the terminal Task back instead. It raises TaskTimeoutError if the deadline elapses.
Schedules
from chopflow import ChopFlowClient
from chopflow.models import OverlapPolicy
with ChopFlowClient.connect("localhost:8000") as client:
sid = client.create_cron_schedule(
"nightly", "build", "0 9 * * *", tags=["ci"], overlap=OverlapPolicy.OVERLAP_SKIP
)
print(client.list_schedules())
client.delete_schedule(sid)
Examples
examples/producer.py— enqueue an echo task and print the result.examples/echo_worker.py— register anechohandler and run until Ctrl+C.
Tests
cd clients/python
pip install -e ".[dev]"
pytest # builds the broker once, then runs 14 integration tests
The test suite builds the Rust broker on an ephemeral port with in-memory storage and exercises the full SDK: enqueue/get, polling, cancellation, failure dead-lettering, schedule CRUD, and worker handler dispatch.
Metadata
Release files for chopflow 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chopflow-0.1.5.tar.gz | 20.0 kB | With provenance | Details for chopflow-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chopflow-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for chopflow-0.1.5-py3-none-any.whl |
Total release size: 38.1 kB
Release files / chopflow-0.1.5.tar.gz
| Download URL | chopflow-0.1.5.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fd2ea44724c4f6afa9c51ac5890aa6197da542f6d5633fb9a6f0500ee81a443
|
|
BLAKE2b-256 checksum How to use checksums |
248b7545582ad3c252b3ca350767542b019baef65e78b745880d0fb8adb3dcb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / chopflow-0.1.5-py3-none-any.whl
| Download URL | chopflow-0.1.5-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e28a6ea876435c1098751479d8ffab83d0531a31a7de912a82b5081f8294602
|
|
BLAKE2b-256 checksum How to use checksums |
ba5d5a019ba88a2165165640da068bdb479645d42b5a5c0436858d678bfe42f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logSecurity for chopflow 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for chopflow-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.