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

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.6.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.6.0
File Size Uploaded Provenance Actions
horsies-0.6.0.tar.gz 1.3 MB With provenance Details for horsies-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for horsies 0.6.0
File Interpreter ABI Platform Actions
horsies-0.6.0-py3-none-any.whl Python 3 none any Details for horsies-0.6.0-py3-none-any.whl

Total release size: 2.6 MB

Release files / horsies-0.6.0.tar.gz

Download URL horsies-0.6.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
688a867d96577d7fdc0e1f5ed880bfb3751b7382e0cd833327e62f7521c86db7
BLAKE2b-256 checksum
How to use checksums
37f07b394e9113061f9e3f2e26162b05b0c3bd57e3d20627c24874a0c4b41eb3
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 3, 2026.

Transparency log

Release files / horsies-0.6.0-py3-none-any.whl

Download URL horsies-0.6.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f22a8016aaa9d4c7dc22b77a2c5079bfbdd781d9b180fa7fa84c408d9506d73a
BLAKE2b-256 checksum
How to use checksums
0e09de49a04cd488922e90679906c3b28ccb3279d410f4ad329a39ec6b703fe0
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 3, 2026.

Transparency log

Security for horsies 0.6.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for horsies-0.6.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 3, 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.6.0 This release

2 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