Skip to main content

PostgreSQL-backed job queue with Rust and Python bindings

Project description

py-pgqrs

pgqrs is a postgres-native, library-only durable execution engine.

Python bindings for the Rust core. Built for Postgres. Also supports SQLite and Turso.

What is Durable Execution?

A durable execution engine ensures workflows resume from application crashes or pauses. Each step executes exactly once. State persists in the database. Processes resume from the last completed step.

Key Properties

  • Postgres-native: Leverages SKIP LOCKED, ACID transactions
  • Library-only: Runs in-process with your application
  • Multi-backend: Postgres (production), SQLite/Turso (testing, CLI, embedded)
  • Type-safe: Rust core with idiomatic Python bindings
  • Transaction-safe: Exactly-once step execution within database transactions

Installation

pip install pgqrs

For local development:

make requirements

Backend Support

py-pgqrs supports all three backends. Choose the right one for your use case:

# PostgreSQL (production)
store = await pgqrs.connect("postgresql://user:pass@localhost:5432/db")

# SQLite (embedded, testing)
store = await pgqrs.connect("sqlite:///path/to/database.db")

# Turso (SQLite-compatible, embedded)
store = await pgqrs.connect("turso:///path/to/database.db")

Usage

Producer + Consumer

import asyncio
import pgqrs

async def main():
    store = await pgqrs.connect("postgresql://localhost/mydb")

    admin = pgqrs.admin(store)
    await admin.install()
    await store.queue("tasks")

    producer = await store.producer("tasks")
    msg_id = await producer.enqueue({"task": "process_image", "url": "..."})
    print(f"Enqueued job {msg_id}")

    consumer = await store.consumer("tasks")
    messages = await consumer.dequeue(batch_size=1)
    for msg in messages:
        print(f"Processing {msg.id}: {msg.payload}")
        await consumer.archive(msg.id)

asyncio.run(main())

Durable Workflow (Python)

import asyncio
import pgqrs

async def main():
    store = await pgqrs.connect("postgresql://localhost/mydb")
    admin = pgqrs.admin(store)
    await admin.install()

    await pgqrs.workflow().name("archive_files").store(store).create()
    consumer = await pgqrs.consumer("worker-1", 8080, "archive_files").create(store)

    await pgqrs.workflow() \
        .name("archive_files") \
        .store(store) \
        .trigger({"path": "/tmp/report.csv"}) \
        .execute()

    messages = await consumer.dequeue(batch_size=1)
    msg = messages[0]

    run = await pgqrs.run().message(msg).store(store).execute()
    step = await run.acquire_step("list_files", current_time=run.current_time)
    if step.status == "EXECUTE":
        await step.guard.success([msg.payload["path"]])

    step = await run.acquire_step("create_archive", current_time=run.current_time)
    if step.status == "EXECUTE":
        await step.guard.success(f"{msg.payload['path']}.zip")

    await run.complete({"archive": f"{msg.payload['path']}.zip"})
    await consumer.archive(msg.id)

asyncio.run(main())

Testing

make test-py PGQRS_TEST_BACKEND=postgres

Documentation

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

pgqrs-0.15.0.tar.gz (206.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pgqrs-0.15.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pgqrs-0.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pgqrs-0.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pgqrs-0.15.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pgqrs-0.15.0-cp38-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

pgqrs-0.15.0-cp38-abi3-musllinux_1_2_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

pgqrs-0.15.0-cp38-abi3-musllinux_1_2_aarch64.whl (4.2 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

pgqrs-0.15.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

pgqrs-0.15.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

pgqrs-0.15.0-cp38-abi3-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

pgqrs-0.15.0-cp38-abi3-macosx_10_12_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file pgqrs-0.15.0.tar.gz.

File metadata

  • Download URL: pgqrs-0.15.0.tar.gz
  • Upload date:
  • Size: 206.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgqrs-0.15.0.tar.gz
Algorithm Hash digest
SHA256 b968259463bc666a1619dcca8a601af1031db432bf6fe7a224023ac891f99d11
MD5 1a0acf1b1dd49e233511363fedd9c4b4
BLAKE2b-256 12e4f9726d2533ded85e72d02387956dc520def0643f2cf56aed609e1e775952

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0.tar.gz:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 59b24ffeaa31ceb257b0c1df06ca847f9359199c9a70475b7834cf82f1a4c2bd
MD5 5fbdf0656c303f12500262c050db86d4
BLAKE2b-256 54fa3c7070170d0f0facd37edc3bf73bc8f0f1b1cb2d7c646c13d894942d4900

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b2c01d97f5edfc47b9657ec9523690b85d3faa997cce281e8cd26040fb4db6fb
MD5 4574e912b7d12c3d5f88b03a0e170ae2
BLAKE2b-256 32821ad801a50f75405a65fdaedad9b490984fcc1ba390cb98e7bd4db26b39ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9f6f8b7e8b08d7f9880ea500ad3c13d70e2a6a62eb6db997c1a5d17ca52cca04
MD5 9aee35c827a648ad49398bf156aad642
BLAKE2b-256 03fdfc40abb2ec2fc89eca058dfca04ddf275e4db157eefa4cf67a82c7400fc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ccb01c614304b14796b739e4bf7ee0308fa6f50fbedc6f25ccb5b2e9323ead91
MD5 1befb9094d84d83c98b0f12b9142dcbb
BLAKE2b-256 c1b29fca156aca1f25fbfcef3af30ca5d9aea812f56df0fa0f99b2ceba9b8429

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: pgqrs-0.15.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f0d35333e594db39477aa2cb92e0f5af90555dac41c78a4e23c206e748572ed4
MD5 0f1d9d2c513c19d8c9ca39684a4ac896
BLAKE2b-256 d60c8f7acd307cad86327f55423752ecf87c01996b78f56f8a6b7873aaeb8c2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-win_amd64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d69ff46ac8fed0110702a5f45715d990e1dac2af65b728e5127ad5952b4ecb86
MD5 6909de0b8c832c27492da25cac605c4c
BLAKE2b-256 346436a2e47b4d48b09b1065caea97a534f2687ce7d013bc8a220184fe318c28

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 04c1d57db6d94107bd9cce3b6d35bc87f33e10a8208becc3c3588f6b1e97e635
MD5 7d0e215f130c2c6df770651f6a017b58
BLAKE2b-256 c68bc860b6f15acbeb384eb324763b4a3e2a05a7586d63c96beb705f07d53364

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bff8b23ee1c97643cce7ea7e6d2c2ce62b710dee72a5462b813cfb0c4fb21b66
MD5 f791de14bd6bf859417614c2405fbc20
BLAKE2b-256 3afa7d0d2ed4016ac84969284ca751269ce1d943e4ffa8a06f09a68b1fc8550c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bd13309b66b8d57c085d0f47ba9c93c2fc3cefbcc09b0738e1e1e7fa5664828e
MD5 af3a77e4549320a006dbfc6d5e2bed55
BLAKE2b-256 4c6876649b17fdf44631bf562d75669da96efbde96637053c8964e1231d26f31

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a32f36e2d33b26ba8afcd67646b820fd9dca7f6e669e51f196b237cc16805842
MD5 8d57366b833e18f574530de285ba16d3
BLAKE2b-256 d873f8006efa8a6645411c699ac79ddbd658d2304e958d721e8a979ee1cc8657

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgqrs-0.15.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pgqrs-0.15.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cfca53f6b6523deb98176f7259c9030fa9bc8efb261919c9afb04cf0241e4fb0
MD5 6341ab0a1d39f523de0b2d697cfe4a9d
BLAKE2b-256 6e87980ec6267f82cee6700a379bec4274b6cec77a5e7dc22cdc7fe1111c0dac

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgqrs-0.15.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on vrajat/pgqrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page