• Stars
    star
    217
  • Rank 182,446 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RQ (Redis Queue) integration for Flask applications

Flask-RQ

https://travis-ci.org/mattupstate/flask-rq.svg?branch=master

RQ (Redis Queue) integration for Flask applications

Resources

Installation

$ pip install flask-rq

Getting started

To quickly start using rq, simply create an RQ instance:

from flask import Flask
from flask.ext.rq import RQ


app = Flask(__name__)

RQ(app)

@job decorator

Provides a way to quickly set a function as an rq job:

from flask.ext.rq import job


@job
def process(i):
    #  Long stuff to process


process.delay(3)

A specific queue name can also be passed as argument:

@job('low')
def process(i):
    #  Long stuff to process


process.delay(2)

get_queue function

Returns default queue or specific queue for name given as argument:

from flask.ext.rq import get_queue


job = get_queue().enqueue(stuff)  # Creates a job on ``default`` queue
job = get_queue('low').enqueue(stuff)  # Creates a job on ``low`` queue

get_worker function

Returns a worker for default queue or specific queues for names given as arguments:

from flask.ext.rq import get_worker


# Creates a worker that handle jobs in ``default`` queue.
get_worker().work(True)
# Creates a worker that handle jobs in both ``default`` and ``low`` queues.
get_worker('default', 'low').work(True)
# Note: These queues have to share the same connection

Configuration

By default Flask-RQ will connect to the default, locally running Redis server. One can change the connection settings for the default server like so:

app.config['RQ_DEFAULT_HOST'] = 'somewhere.com'
app.config['RQ_DEFAULT_PORT'] = 6479
app.config['RQ_DEFAULT_PASSWORD'] = 'password'
app.config['RQ_DEFAULT_DB'] = 1

Queue connection can also be set using a DSN:

app.config['RQ_LOW_URL'] = 'redis://localhost:6379/2'

More Repositories

1

flask-sqlalchemy

Adds SQLAlchemy support to Flask
Python
4,134
star
2

blinker

A fast Python in-process signal/event dispatching system.
Python
1,647
star
3

flask-debugtoolbar

A toolbar overlay for debugging Flask applications
JavaScript
912
star
4

flask-caching

A caching extension for Flask
Python
882
star
5

flask-security

Quick and simple security for Flask applications
Python
625
star
6

flask-mail

Flask-Mail adds SMTP mail sending to your Flask applications
Python
595
star
7

flask-jwt

JWT (JSON Web Tokens) for Flask applications
Python
563
star
8

flask-principal

Identity management for Flask applications
Python
494
star
9

flask-session

Server side session extension for Flask
Python
477
star
10

flask-social

OAuth Provider Integration for Flask-Security
Python
245
star
11

flask-openid

Flask-OpenID adds openid support to flask applications
Python
234
star
12

flask-classful

Class based views for Flask
Python
222
star
13

cachelib

Extract from werkzeug.cache
Python
131
star
14

flask-jsonschema

JSON request validation with jsonschema for Flask applications
Python
64
star
15

flask-alembic

Integrate Alembic with Flask.
Python
43
star
16

secure-cookie

Secure cookies and sessions for WSGI
Python
32
star
17

flask-environments

Environment tools and configuration for Flask applications
Python
30
star
18

flask-negotiate

Content negotiation for Flask apps
Python
12
star
19

flask-stache

Mustache templates for Flask apps
Python
10
star
20

flask-orjson

A Flask/Quart JSON provider using the fast orjson library.
Python
8
star
21

click-bash4.2-completion

Support Bash 4.2 completion for Click 8.0.x
Python
2
star
22

.github

2
star
23

flask-ujson

A Flask/Quart JSON provider using the fast ujson library.
Python
2
star
24

flask-api-examples

1
star