Skip to main content

Adds Dramatiq support to your Flask application

Project description

Flask-Dramatiq

Flask-Dramatiq plugs Dramatiq task queue in your Flask web application.

// Features //

  • Configure Dramatiq from Flask configuration.
  • Ensure Flask app is available to Dramatiq actor.
  • Add worker command to Flask CLI.
  • Enable Flask Application factory.
  • Handle multiple brokers with configurable prefix.
  • Integrates periodiq. Optionnal.

Full documentation at flask-dramatiq.readthedocs.io.

// Installation and Usage //

Flask-Dramatiq is licensed under BSD-3-Clause. Add flask-dramatiq to your project:

$ poetry add flask-dramatiq

Then use Dramatiq object as a regular Flask extension:

from flask import Flask
from flask_dramatiq import Dramatiq

app = Flask(__name__)
dramatiq = Dramatiq(app)

@dramatiq.actor()
def my_actor():
    ...

@app.route("/")
def myhandler():
    my_actor.send()

Flask-Dramatiq adds two configuration keys:

  • DRAMATIQ_BROKER, points to broker class like dramatiq.brokers.rabbitmq.RabbitmqBroker or dramatiq.brokers.redis.RedisBroker.
  • DRAMATIQ_BROKER_URL is passed as url keyword argument to broker class.

Now run worker program to consume messages and execute tasks in the background:

$ flask worker --processes=1

A complete flask app is available in project source tree example.py.

// Credit and Support //

Feel free to open an issue or suggest a merge request on Gitlab project page. Contribution welcome!

The project is based on Bogdanp/flask_dramatiq_example.

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

flask-dramatiq-0.6.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

flask_dramatiq-0.6.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file flask-dramatiq-0.6.0.tar.gz.

File metadata

  • Download URL: flask-dramatiq-0.6.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0b1 CPython/3.6.8 Linux/4.19.0-5-amd64

File hashes

Hashes for flask-dramatiq-0.6.0.tar.gz
Algorithm Hash digest
SHA256 63709e73d7c8d2e5d9bc554d1e859d91c5c5c9a4ebc9461752655bf1e0b87420
MD5 4181ec7670ea8291366797079f5ef2d8
BLAKE2b-256 e8b0c03d2184693ddf6a9f8e8b79d72670446f38758f6c067082b86a50bda8bd

See more details on using hashes here.

Provenance

File details

Details for the file flask_dramatiq-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: flask_dramatiq-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0b1 CPython/3.6.8 Linux/4.19.0-5-amd64

File hashes

Hashes for flask_dramatiq-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d4a9289721577f726183f7c44c6713a16bbdff54b946f27abc2ffcc65768adf
MD5 878bc334d29598304287d87d34df4f81
BLAKE2b-256 4952496d15ad26f3586fb3addfd71cea493115a5de528ec4eae6ed44b2c0577c

See more details on using hashes here.

Provenance

Supported by

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