Skip to content

v0.2.0 - Reach the running task from anywhere

Choose a tag to compare

@Kludex Kludex released this 17 Aug 13:12
· 44 commits to main since this release
8a1c97b

🐘 Reach the running task from anywhere

pgtask is a task queue, scheduler, and durable workflow runtime that keeps every piece of state in PostgreSQL. No broker, no coordinator, no extension.

This release makes the current task reachable from code that never received it, so a framework calling back into your handler can still checkpoint through pgtask.

pip install pgtask==0.2.0

🚀 Ambient task context in the Python SDK

A handler receives its Task as an argument, which is enough only while you control every frame beneath it. A framework that calls back into your code does not forward it: nothing between agent.run() and the hook it invokes knows the task exists.

from pgtask import get_current_task

task = get_current_task()
if task is not None:
    result = await task.step("call-model", call_model)

It returns the task inside a handler and None outside, so library code can fall back instead of failing.

The worker sets a ContextVar around each invocation, next to the OpenTelemetry context it already attaches. Two handlers running under concurrency > 1 each see their own task, and a step operation sees the task that started it - the worker gives every invocation its own copied context, and step copies that context at call time.

This removes the reason for a @durable_task decorator that users have to remember to apply. See Reach the task from anywhere below the handler for the details.


📖 Readable package pages

Every published crate now has a README. crates.io and docs.rs showed one line of description before this, and the Python wheel opened with a title and a code block.

The pgtask crate README is also its crate documentation, so both of its examples are compiled as doctests and cannot drift from the API they describe.

The repository README leads with the published artifacts rather than asking you to clone and run Tilt.


📦 What ships

Artifact Contents
Rust crates pgtask, pgtask-core, pgtask-postgres, pgtask-worker, pgtask-otel, pgtask-cli, pgtask-web
Python wheel Stable ABI for CPython 3.10+ on Linux, macOS, and Windows, plus a source distribution
npm @pgtask/client for Node.js 20 or newer
Go module github.com/Kludex/pgtask/sdks/go for Go 1.25 or newer
Container image ghcr.io/kludex/pgtask:0.2.0, multi-architecture, Sigstore signed
Helm chart Signed OCI chart with per-queue worker Deployments, migration Job, probes, and optional autoscaling

PostgreSQL 17 and 18 are both tested.


⬆️ Upgrading

No schema migration, and the storage protocol is unchanged, so a 0.1.3 worker and a 0.2.0 worker can claim from the same queue during a rolling upgrade.


⚠️ Not ready for production

This is a preview. The engine passes its suite against real PostgreSQL and has never run a production workload. The Rust, Python, SQL, CLI, and telemetry surfaces may change before 1.0; the storage protocol range is the compatibility contract in the meantime.

Delivery is at least once. A handler can finish an external side effect and lose its lease before recording the result, so handlers must be safe to run again.


Documentation: https://kludex.github.io/pgtask/

Full changelog: v0.1.3...v0.2.0