Skip to main content

z4j Flask framework adapter (Apache 2.0)

Project description

z4j-flask

PyPI version Python License

License: Apache 2.0

Flask framework adapter for z4j. Flask-extension shape - one Z4J(app) call and the agent boots on the first request.

Install

Pick your task engine and install with the matching extra. Each extra pulls the engine adapter AND its companion scheduler in one shot, so a fresh install never needs a second command.

pip install z4j-flask[celery]       # Celery + celery-beat
pip install z4j-flask[rq]           # RQ + rq-scheduler
pip install z4j-flask[dramatiq]     # Dramatiq + APScheduler
pip install z4j-flask[huey]         # Huey + huey-periodic
pip install z4j-flask[arq]          # arq + arq-cron
pip install z4j-flask[taskiq]       # TaskIQ + taskiq-scheduler
pip install z4j-flask[all]          # every engine (CI / kitchen sink)

pip install z4j-flask (no extra) installs only the framework adapter. That's useful if you already manage engine packages elsewhere; otherwise always pick an engine extra.

Configure

Register the extension the standard Flask way:

from flask import Flask
from z4j_flask import Z4J

app = Flask(__name__)
app.config.update(
    Z4J_BRAIN_URL="https://z4j.internal",
    Z4J_TOKEN="z4j_agent_...",        # minted in the brain dashboard
    Z4J_PROJECT_ID="my-project",
)

z4j = Z4J(app)

Or use the application-factory pattern:

z4j = Z4J()

def create_app():
    app = Flask(__name__)
    app.config.from_envvar("FLASK_CONFIG")
    z4j.init_app(app)
    return app

On the first request, the agent connects to the brain and z4j's dashboard populates with every Celery / Dramatiq task your workers discover.

What it does

Piece Purpose
Z4J(app) Flask extension; hooks into the app lifecycle
Config from app.config Reads Z4J_* keys - idiomatic Flask configuration
Lazy boot Agent starts on first request, not at import time (so flask --help stays fast)
Teardown integration Flushes the event buffer on SIGTERM / graceful shutdown

Reliability

z4j-flask follows the project-wide safety rule: z4j never breaks your Flask app. Agent failures are caught at the boundary, logged, and swallowed.

Documentation

License

Apache 2.0 - see LICENSE. Your Flask application is never AGPL-tainted by importing z4j_flask.

Links

Project details


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.1.2.tar.gz (26.6 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.1.2-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: z4j_flask-1.1.2.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for z4j_flask-1.1.2.tar.gz
Algorithm Hash digest
SHA256 91deab664db152af79f6187ee667b156afe393f16c60f1366697a20a6e244250
MD5 b6205cfa87b127e0af8f631cd27a2784
BLAKE2b-256 0147aa3657ff5a1d77749ac2f9d6ddb03c88b348de20ebc2a89f9a6f7801871d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: z4j_flask-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for z4j_flask-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 873dd85de03031e2d6ec945c9cb416d37154d5da4efbf59b9a3b09f19287be40
MD5 6e114e1497e536075375450a688a1c7d
BLAKE2b-256 71af50fa4b304a7c5366a9ccd42fdb2e59ef87ad6083b9881c93aa70a09d252a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page