Flask
v1.13.0 Apache-2.0z4j-flask ยท Upstream project
Flask extension pattern. One line to install.
Standard Flask extension shape (Z4J(app)). Finds your Celery app through app.config['CELERY_APP'], app.extensions['celery'] or app.celery_app, and the other engines through their Flask config keys. Reads Z4J_* from the environment or app.config. No monkey-patching, no magic.
- Latest
- v1.13.0
- Released
- 2026-10-19
- License
- Apache-2.0
Install
pip install z4j-flask Pick an engine
Flask + any task engine
Every extra pulls the engine adapter AND its companion scheduler in one shot, so a fresh install never needs a second command.
| Engine | Install command | Bundled scheduler |
|---|---|---|
| Celery recommended | pip install z4j-flask[celery] | celery-beat |
| RQ | pip install z4j-flask[rq] | rq-scheduler |
| Dramatiq | pip install z4j-flask[dramatiq] | APScheduler |
| Huey | pip install z4j-flask[huey] | huey-periodic |
| arq | pip install z4j-flask[arq] | arq-cron |
| TaskIQ | pip install z4j-flask[taskiq] | taskiq-scheduler |
| Every engine (CI / kitchen sink) |
pip install z4j-flask[all]
| all of the above |
pip install z4j-flask with no extra installs only the framework adapter. Pick an engine extra for the normal case.
Wire it in
from flask import Flask
from z4j_flask import Z4J
app = Flask(__name__)
z4j = Z4J(app) # reads Z4J_* from the environment or app.config["Z4J_*"] Verify
Confirm the agent reaches the brain
Run the doctor as the same user the service runs under. It checks the on-disk buffer path, DNS, TCP and TLS to the brain, and that the agent runtime starts locally (the Django doctor also lists the engines it detects); it exits 0 on all-green, 1 on any failure. It does not prove the WebSocket upgrade or that the brain accepts the token, so confirm the authenticated connection in the agent log and the dashboard.
python -m z4j_flask doctor
Catches the gunicorn-under-www-data silent startup failure (the agent auto-relocates the buffer to $TMPDIR/z4j-{uid} when $HOME is unwritable), DNS failures, and firewall or certificate problems on the path to the brain. It does not check the token or project id; a rejected token shows up in the agent log as a 4401 close. Add --no-websocket to skip the local runtime probe, --json for scripts. Reference.
What you get
Flask-specific features
Engine pairings
Flask works with every z4j engine
The framework adapter handles lifecycle and config. Any engine adapter slots in alongside.
Celery
The industry standard, covered end-to-end.
Learn more
RQ
Lightweight Redis queue, fully instrumented.
Learn more
Dramatiq
Middleware-driven Dramatiq observability.
Learn more
Huey
Lightweight Redis/SQLite queue, first-class.
Learn more
arq
Async Redis queue for FastAPI-era Python.
Learn more
taskiq
Broker-agnostic async task framework.
Learn moreOther frameworks