z4j-flask
The Flask framework adapter for z4j.
Adds the z4j agent into your Flask app via a one-line Z4J(app)
initializer. It registers installed engine adapters only when their required
native handles are configured on the Flask app (CELERY_APP, RQ_APP or
RQ_REDIS_URL, ARQ_REDIS_SETTINGS, HUEY, or TASKIQ_BROKER). Dramatiq can
instead use a process-global broker that already has registered actors.
Compatibility
- Flask 3.1.3+ (no upper cap)
- Python 3.11+
Pair with an engine adapter (z4j-celery, z4j-rq, z4j-dramatiq, z4j-huey, z4j-arq, z4j-taskiq); each engine adapter carries its own upstream floor.
Full per-adapter matrix at https://z4j.dev/reference/compatibility/.
What it ships
- One-line install,
Z4J(app)and the agent connects on the next worker boot - Configured engine discovery, supports multiple installed adapters when each adapter's required native handle is present in Flask config
- TaskIQ middleware discovery,
TASKIQ_BROKERattaches z4j capture without guessing an event loop; TaskIQ broker startup binds its actual owner loop - Per-task metadata from supporting engine adapters;
z4j-celery,z4j-rq, andz4j-dramatiqexpose@z4j_metarather than this framework package defining one - Service-user safe, auto-relocates the local outbound buffer
to
$TMPDIR/z4j-{uid}when$HOMEis unwritable
Install
pip install z4j-flask z4j-celery z4j-celerybeat
Wire it into your app:
from flask import Flask
from myproject.celery import app as celery_app
from z4j_flask import Z4J
app = Flask(__name__)
app.config["CELERY_APP"] = celery_app
Z4J(app) # reads Z4J_TOKEN, Z4J_HMAC_SECRET, Z4J_BRAIN_URL, Z4J_PROJECT_ID
Mint the agent from the dashboard's Agents page and retain both values it shows: the bearer token and the HMAC secret.
For TASKIQ_BROKER, initialize Z4J(app) before the component that starts the
broker. Flask discovery attaches the middleware, and TaskIQ's real broker
startup binds its owner loop. A separate TaskIQ worker process still needs its
own agent and must attach before the TaskIQ CLI starts the broker.
Reliability
- Agent startup and delivery failures are logged and isolated from Flask request handlers and worker code; capture hooks make no brain network request inline.
- Engine event queues and the SQLite outbound buffer are bounded. Queue overflow drops new events and buffer pressure evicts oldest rows; both losses are logged.
Documentation
Full docs at z4j.dev/frameworks/flask/.
License
Apache-2.0, see LICENSE.
Links
- Homepage: https://z4j.com
- Documentation: https://z4j.dev
- PyPI: https://pypi.org/project/z4j-flask/
- Issues: https://github.com/z4jdev/z4j-flask/issues
- Changelog: CHANGELOG.md
- Security: security@z4j.com (see SECURITY.md)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file z4j_flask-1.9.1.tar.gz.
File metadata
- Download URL: z4j_flask-1.9.1.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
157790134d8ff75c46c0ddf6d8bf65d08137c5edb43130dff2672542a616efd3
|
|
| MD5 |
e1be3bce91ade018a723cac9b4451a3a
|
|
| BLAKE2b-256 |
c49d6d7d318aaea885dd7fd92da6d22d31195b5c3ba5e4a01d09d23437b60ffd
|
File details
Details for the file z4j_flask-1.9.1-py3-none-any.whl.
File metadata
- Download URL: z4j_flask-1.9.1-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d76eaf904ed65c66a4ff1f3738b03a3c98551c0cb65cd5381d82702ac1ea1501
|
|
| MD5 |
f758c2c8f8cfb2d76c953f614f40de02
|
|
| BLAKE2b-256 |
15fcb7ca9fc8c6cf190097f6839dd86a737692b979fedb2bb49350f47a447044
|