Adds Dramatiq support to your Flask application
// Features //
- Configure Dramatiq from Flask configuration.
- Ensure Flask app is available to Dramatiq actor.
workercommand to Flask CLI.
- Enable Flask Application factory.
- Handle multiple brokers with configurable prefix.
// Installation and Usage //
Flask-Dramatiq is licensed under BSD-3-Clause. Add
flask-dramatiq to your
$ poetry add flask-dramatiq
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_BROKER_URLis passed as
urlkeyword 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.
// Multiple brokers //
You may need multiple broker, e.g. by associating a broker with a blueprint. Flask-Dramatiq supports this. Give other broker a name and run a dedicated worker for it.
bluebroker = Dramatiq(name='bluebroker') # Configuration: BLUEBROKER_BROKER_URL = 'rabbitmq://…'
Now run it :
$ flask worker bluebroker
// Using Dramatiq CLI //
You can still use
dramatiq CLI by declaring a file containing:
app = create_app() broker = dramatiq.broker
dramatiq CLI with
some_module:broker as usual.
// 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.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size flask_dramatiq-0.3.0-py3-none-any.whl (9.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size flask-dramatiq-0.3.0.tar.gz (5.1 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for flask_dramatiq-0.3.0-py3-none-any.whl