(Cookbook, Changelog, Source Code)

Version on PyPI BSD-3-Clause Continuous Integration report

Welcome to Flask-Dramatiq’s documentation. Flask-Dramatiq is a Flask extensions to bridge Dramatiq task queue in your web app.


  • Setup 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.
  • Automatic code reload on change if DEBUG is set.

Get started

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

$ poetry add flask-dramatiq

Then use Dramatiq object as a regular Flask extension. The Dramatiq object replaces the dramatiq module.

from flask import Flask
from flask_dramatiq import Dramatiq

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

def my_actor():

def myhandler():

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 Dramatiq broker class.

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

$ flask worker --processes=1

That’s it! A complete flask app is available in project source tree example.py