Flask-RQ
March 4, 2025 ยท View on GitHub
Flask-RQ is a Flask/Quart extension that background job execution using RQ. RQ allows queueing functions to be run in separate worker processes, allowing long-running jobs to run in the background without blocking the web app from returning a response quickly. Flask-RQ allows configuring RQ using Flask's config, and handles executing jobs in the application context, so other services like database connections are available.
Pallets Community Ecosystem
Important
This project is part of the Pallets Community Ecosystem. Pallets is the open
source organization that maintains Flask; Pallets-Eco enables community
maintenance of related projects. If you are interested in helping maintain
this project, please reach out on the Pallets Discord server.
Installation
Install from PyPI:
$ pip install flask-rq
Example
from flask import Flask, g
from flask_rq import RQ
app = Flask(__name__)
rq = RQ(app)
@rq.job
def send_password_reset_job(user_id: int) -> None:
...
@app.route("/auth/send-password-reset")
def send_password_reset():
send_password_reset_job.enqueue(user_id=g.user.id)
return "Check your email!"
$ flask rq worker