Skip to main content

z4j-flask

PyPI version Python License

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_BROKER attaches 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, and z4j-dramatiq expose @z4j_meta rather than this framework package defining one
  • Service-user safe, auto-relocates the local outbound buffer to $TMPDIR/z4j-{uid} when $HOME is 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z4j_flask-1.9.0.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

z4j_flask-1.9.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file z4j_flask-1.9.0.tar.gz.

File metadata

  • Download URL: z4j_flask-1.9.0.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

Hashes for z4j_flask-1.9.0.tar.gz
Algorithm Hash digest
SHA256 10e634784e2ffecc71d55bb46bb1391b67fdc299e243c0db68ad1bbcb742b683
MD5 7a429a8017fa3011ab8f6e57684e6a7f
BLAKE2b-256 4a9723071b2497bb609d99cee0f6166899fa9f693afd75b3acc036f28dab6396

See more details on using hashes here.

File details

Details for the file z4j_flask-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: z4j_flask-1.9.0-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

Hashes for z4j_flask-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b9e36646d8981b3f2ad5cb97dbf302afc3524f91f34b5a4a7733b0a731d97b
MD5 48aa98916e37d589084fc1b6087e030a
BLAKE2b-256 b1e355a21fcf8dbcdee30adffb0c6d3cae8ca48ec80cd6b8b13432b3e4d2ae02

See more details on using hashes here.

Release history Release notifications | RSS feed

1.10.0

2 files

1.9.1

2 files

This release

1.9.0 This release

2 files

1.8.0

2 files

1.7.0

2 files

1.6.9

2 files

1.6.8

2 files

1.6.7

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.2

2 files

1.1.0

2 files

1.0.4

2 files

1.0.3

1 file

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

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