Huey
v1.13.0 Apache-2.0z4j-huey ยท Upstream project
Lightweight Redis/SQLite queue, first-class.
Supports Huey 2.4 and newer, including Huey 3. Event capture uses huey.signals. cancel_task calls revoke_by_id to prevent pending work from starting; it never interrupts running work. Pair with z4j-hueyperiodic to surface @periodic_task schedules.
- Latest
- v1.13.0
- Released
- 2026-10-19
- License
- Apache-2.0
Install
pip install z4j-huey Native actions
-
submit_task -
retry_task (complete replacement inputs) -
cancel_task (pending revoke only)
Not supported
- running-task cancellation
- bulk_retry
- requeue_dead_letter
- list_dead_letters
- purge_queue
- restart_worker
- rate_limit
These are engine-level limitations: the underlying engine does not expose the primitives required to support these actions.
Wiring
How z4j plugs in
Event capture
huey.signals decorator, installed via adapter.connect_signals().
Reconciliation
Huey result store (storage.peek_data via get_raw). Returns success, failure or unknown.
Install
Add z4j to a Huey app
z4j itself is one container or one Python process. The agent is a pip package in your app's environment that opens one outbound connection to it.
Huey is the simplest of the bunch: small surface, no result backend by default, file-backed scheduler optional. With z4j it gets a dashboard it traditionally lacks, safe submit, replacement-input retry, and pending-only revoke controls, plus an audit log for operator actions. Revoke prevents pending work from starting; it does not interrupt running work.
1. Run z4j
pip install z4j && z4j serve First boot prints a setup URL to stderr. Open it, create the first admin, and mint a token and HMAC secret for the agent. Docker and PostgreSQL setups are in the install guide.
Django + Huey
2. Install the agent
pip install z4j-django[huey] 3. Wire it into Django
# settings.py
INSTALLED_APPS += ["z4j_django"]
Z4J = {
"brain_url": env("Z4J_BRAIN_URL"),
"token": env("Z4J_TOKEN"),
"hmac_secret": env("Z4J_HMAC_SECRET"),
"project_id": env("Z4J_PROJECT_ID"),
"agent_name": env("Z4J_AGENT_NAME", default=None),
}
# z4j-django discovers only Celery in the web process; the Huey
# worker process needs its own hook (see below). Task lifecycle events come from the Huey worker process, which needs the z4j-huey worker hook. Full guide: Django integration and Huey engine docs.
Flask + Huey
2. Install the agent
pip install z4j-flask[huey] 3. Wire it into Flask
from flask import Flask
from z4j_flask import Z4J
app = Flask(__name__)
app.config["HUEY"] = "myapp.tasks:huey"
z4j = Z4J(app) # reads Z4J_* from the environment or app.config["Z4J_*"] Task lifecycle events come from the Huey worker process, which needs the z4j-huey worker hook. Full guide: Flask integration and Huey engine docs.
FastAPI + Huey
2. Install the agent
pip install z4j-fastapi[huey] 3. Wire it into FastAPI
from myapp.tasks import huey # your Huey instance
from fastapi import FastAPI
from z4j_fastapi import z4j_lifespan
# The engine handle registers the Huey adapter in the web process.
app = FastAPI(
lifespan=z4j_lifespan(
huey=huey,
),
) Task lifecycle events come from the Huey worker process, which needs the z4j-huey worker hook. Full guide: FastAPI integration and Huey engine docs.
Huey in a plain Python worker
2. Install the agent
pip install z4j-bare z4j-huey 3. Start it at worker boot
# The module your Huey consumer imports
from z4j_bare import install_agent
from z4j_huey import HueyEngineAdapter
from myapp.tasks import huey # your Huey instance
runtime = install_agent(engines=[HueyEngineAdapter(huey=huey)]) Full guide: Plain Python integration and Huey engine docs.
Scheduler
Huey @periodic_task with z4j
Manage code-defined Huey schedules with durable overrides.
Huey @periodic_task runs its schedules as Huey tasks. Manages Huey crontab definitions through a private persistent override file consumed by the actual periodic consumer. Dashboard changes do not rewrite Python code.
What z4j can do with Huey @periodic_task
- List schedules
- Create schedule
- Update schedule
- Delete schedule
- Enable / disable
- Trigger-now
Limitations
- Requires matching z4j package versions and NativeScheduleControl in the periodic consumer
- UTC crontab definitions; custom Python predicates are not managed
- New schedules invoke registered tasks; preserve the override file
Package z4j-hueyperiodic.
Reference: Huey @periodic_task docs. For schedules edited from the dashboard on any engine, see z4j-scheduler; every option side by side is on the schedulers overview.
Included
What you get on top of Huey
- Persistent Huey task history in PostgreSQL or SQLite
- Task controls the adapter advertises, and nothing it cannot execute safely
- Issues: repeated failures grouped by fingerprint
- RBAC with invitations and password reset
- HMAC-chained audit log of operator actions
- Notifications: email, Slack, Telegram, webhook
The agent packages (z4j-huey and the framework adapters) are Apache 2.0. Importing them into your app does not affect its licensing. z4j itself is AGPL-3.0-or-later and runs in its own process.
More engines