Adds Dramatiq support to your Flask application
Project description
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.
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 likedramatiq.brokers.rabbitmq.RabbitmqBroker
ordramatiq.brokers.redis.RedisBroker
.DRAMATIQ_BROKER_URL
is passed asurl
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
Release history Release notifications | RSS feed
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
Hashes for flask_dramatiq-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e7cdb3ef198dcc49b1ffca3ca07090b49df9002a6916ecaa999a27978b5abe4 |
|
MD5 | 0a8b0268382246b092323ad1ba8d9e1b |
|
BLAKE2b-256 | baaedb70721f3ea10b72e0a408f971c96aaf5fde1de3cf49358e05a224451d5d |