Skip to main content

Horsies Logo

Horsies

PostgreSQL-backed background task queue and workflow engine for Python.

Full Documentation | PyPI | GitHub


This library is a response to frustrations I had with existing task queue and workflow libraries.

Most businesses need durable, observable systems with strong execution guarantees. Traditional queues do not give you that out of the box. You end up writing tedious state machines around them, and your execution state gets mixed into your business logic, because your execution layer was never durable.

Horsies lets you declare your conditional business logic as tasks and workflows, without managing execution state on top of it.

Python type hints stop at the queue. Once you send a task, its arguments become JSON, and you find out a type was wrong when a worker fails, and only if you run something like Prometheus or Sentry in production.

Horsies solves both. The function signature is the contract, and every value is held to it for its whole life. A type that cannot survive the trip is refused when you define the task. A wrong value is refused when you send it, before anything is stored. What a task returns is checked before it is saved, and what you read back is the type you declared, or a clear error. Workflows get the same treatment: wire a task that returns a string into a parameter that takes an int, and it fails at definition, not halfway through a run.

Horsies makes it incredibly hard to have a runtime failure because of types. If one happens anyway, you do not need a heavy service to see it. The failure is stored with the task as a named error, with the type it expected and the type it got, and the monitoring web UI shows it from a simple FastAPI app that you can mount in your own server.

That promise about execution state is the reason Horsies exists. There is no unclear state, because nothing lives in memory. Any work that needs to be done is claimed and leased with an identity, so even a crash is traceable: you can see which worker held the task, when, and what happened to it.

There is one way for a task to fail. Every task returns its value or a TaskError with a code, and that is part of the task contract. Your error cases are defined and handled, and they do not disappear into whatever happened to raise. This matters even more when an AI coding agent writes the task: it cannot skip the error path, because the contract does not let it.

The library's own failures use the same form, sorted into families, so you can tell a failing broker from a task that broke its contract, from a task that timed out, from a business error you chose to return. Retries follow those codes, so you decide which failures are worth another attempt.

Those state machines do two jobs: they remember what happened to each step, and they decide what runs next. Horsies does the first job for you, because every task ends in a typed value or a named error, and that outcome is stored. That leaves the decision, and you declare it. A workflow is a graph of tasks: each node says what it waits for and what happens if that fails, and the workflow says what counts as success. A step can even take a failure as its input and act on it. A whole workflow can be one node in another, so your largest process is built from the same few declarations as your smallest, and your tasks keep only your business logic.

The worker model is extremely resilient. By default, each running task has a child process to itself, so a segfault, an out-of-memory kill or a timeout ends that task and no other. The worker sees it at once and starts a new child in that slot. It also knows whether your code had started: a task that had not goes back to the queue, and a task that had runs again only if you asked for that, because its side effects may already have happened. If the whole worker dies, its children stop with it, so a task cannot keep running next to its own retry, and another worker recovers what it held. Tasks that only wait on the network can share a process, when you mark them and set up the worker for it. That is a different deal, and you choose it per task. At its timeout a shared task is cancelled, or left to run if it runs on a thread. If it does not stop, the process takes no new task, and the worker ends it once no task in it has time left. A crash in that process, or a task that blocks it, ends the tasks in it too. One thing does not change: a retry never starts while the earlier attempt still runs. That covers the work a task awaits and the asyncio tasks it starts. A thread, a scheduled callback or a detached subprocess that a task starts and does not wait for is outside that promise.

Monitoring comes with the library, because the state Horsies runs on is the state you want to see. The web UI reads the same records your workers write, so there is no agent or exporter to set up, and you get the live state and the history of your tasks, queues, workflows, schedules and workers, with the load on each worker over time. Errors are grouped by their code families, so a spike of broker failures does not look like a spike of business errors. A workflow run opens as its graph, with its failed nodes one click away and its child workflows inside it, and a task opens down to each attempt: which worker ran it, when, and what came back.

You cannot boot an invalid configuration. Workers and schedulers validate your app before they start, and horsies check runs the same validation in CI, with no worker and no database. It imports your tasks, runs your workflow builders and checks every graph, queue and retry policy, so these mistakes never reach runtime. A problem is reported the way a compiler reports it, with a stable HRS code, the source line and a suggested fix, so an AI coding agent can read the error and correct itself.

You can run as many schedulers as you want for high availability, without worrying about double fires. Each schedule is locked in Postgres while it fires, and each slot has one fixed task id, so a second scheduler cannot enqueue it twice.

The feature set of this library is a way to judge how many sharp edges have already been thought through and solved for you.

Horsies is pre-1.0. Breaking API changes can come in minor releases, and the changelog documents each one.

Metadata

Release files for horsies 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for horsies 0.8.0
File Size Uploaded Provenance Actions
horsies-0.8.0.tar.gz 4.2 MB With provenance Details for horsies-0.8.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for horsies 0.8.0
File Interpreter ABI Platform Actions
horsies-0.8.0-cp313-abi3-manylinux_2_28_x86_64.whl CPython 3.13 abi3 Linux glibc 2.28+ x86-64 Details for horsies-0.8.0-cp313-abi3-manylinux_2_28_x86_64.whl
horsies-0.8.0-cp313-abi3-manylinux_2_28_aarch64.whl CPython 3.13 abi3 Linux glibc 2.28+ ARM64 Details for horsies-0.8.0-cp313-abi3-manylinux_2_28_aarch64.whl
horsies-0.8.0-cp313-abi3-macosx_11_0_arm64.whl CPython 3.13 abi3 macOS 11.0+ ARM64 Details for horsies-0.8.0-cp313-abi3-macosx_11_0_arm64.whl

Total release size: 39.0 MB

Release files / horsies-0.8.0.tar.gz

Download URL horsies-0.8.0.tar.gz
Size 4.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0cb441652096571f28a40b924f1af4e946b243508c90a55b022f1c70f8507e62
BLAKE2b-256 checksum
How to use checksums
bda99cc33a0d9178330db58d3fbe02f7b2b8e13efc1d0373ebfa6d81fe3bca70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Nov 21, 2026.

Transparency log

Release files / horsies-0.8.0-cp313-abi3-manylinux_2_28_x86_64.whl

Download URL horsies-0.8.0-cp313-abi3-manylinux_2_28_x86_64.whl
Size 11.9 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d96a91145f87ee1fedf3aa460891f094d2f231405bfabf8fb54e7159e551a425
BLAKE2b-256 checksum
How to use checksums
df32d0c267cd4490136d83785c3dbb4123a80cf68c4f5470702dba68c9546ffa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Nov 21, 2026.

Transparency log

Release files / horsies-0.8.0-cp313-abi3-manylinux_2_28_aarch64.whl

Download URL horsies-0.8.0-cp313-abi3-manylinux_2_28_aarch64.whl
Size 11.9 MB
Tags CPython 3.13 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
8e2dca214a5d9aaef2bb9b73721f6277dfcbc84d0f0848f8d9aab676519afc75
BLAKE2b-256 checksum
How to use checksums
54f9974cac2c444a8fea060e2614578f861a371ece525e826ac6b477d86caec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Nov 21, 2026.

Transparency log

Release files / horsies-0.8.0-cp313-abi3-macosx_11_0_arm64.whl

Download URL horsies-0.8.0-cp313-abi3-macosx_11_0_arm64.whl
Size 11.0 MB
Tags CPython 3.13 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6098f390f8cf61ef822be2a94b09372628efbf3577b18c582c8082f8d379a769
BLAKE2b-256 checksum
How to use checksums
3b0fc20b83ac4b1fb39679ea8cfb7a64557f0dfc9d7d7e9bb54bc58fa41cdfab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Nov 21, 2026.

Transparency log

Security for horsies 0.8.0

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

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for horsies-0.8.0.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 Nov 21, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.8.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page