RQ: Simple Job Queues for Python with Redis/Valkey

This repository profile is provided by osrepos.com, an open source repository discovery platform.

RQ: Simple Job Queues for Python with Redis/Valkey

Summary

RQ (Redis Queue) is a straightforward Python library designed for managing job queues and processing tasks in the background. It leverages Redis or Valkey for backend storage, offering a low barrier to entry while ensuring excellent scalability for applications of all sizes. Developers can easily integrate RQ into their web stacks to handle asynchronous operations efficiently.

Repository Information

Analyzed by OSRepos on August 5, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

RQ (Redis Queue) is a simple yet powerful Python library for managing job queues and processing tasks asynchronously in the background. Backed by Redis or Valkey, RQ is designed for ease of use, allowing developers to quickly integrate background processing into their applications. It offers a robust solution for projects ranging from small utilities to large-scale enterprise systems, providing excellent scalability and reliability.

Installation

Getting started with RQ is straightforward. You can install the latest version using pip:

$ pip install rq

RQ requires a running Redis or Valkey server (version 5 or higher for Redis, 7.2 or higher for Valkey).

Examples

Basic Job Enqueueing

To enqueue a job, first define your function, then create an RQ queue and add the function call to it:

import requests
from redis import Redis
from rq import Queue

def count_words_at_url(url):
    """Just an example function that's called async."""
    resp = requests.get(url)
    return len(resp.text.split())

# Create an RQ queue
queue = Queue(connection=Redis())

# Enqueue the function call
job = queue.enqueue(count_words_at_url, 'https://stamps.id')
print(f"Job ID: {job.id}")

Job Prioritization

RQ allows you to prioritize jobs in two ways:

  1. Enqueue at the front:
    job = queue.enqueue(count_words_at_url, 'https://stamps.id', at_front=True)
    
  2. Use multiple queues: Define separate queues for different priorities and start workers with a prioritized list.
    from rq import Queue
    high_priority_queue = Queue('high', connection=Redis())
    low_priority_queue = Queue('low', connection=Redis())
    
    high_priority_queue.enqueue(urgent_task)
    low_priority_queue.enqueue(non_urgent_task)
    
    Then, start a worker:
    $ rq worker high low
    

Scheduling Jobs

Schedule jobs to run at a specific time or after a delay:

from datetime import datetime, timedelta
# Schedule job to run at 9:15, October 10th
job = queue.enqueue_at(datetime(2019, 10, 10, 9, 15), say_hello)

# Schedule job to run in 10 seconds
job = queue.enqueue_in(timedelta(seconds=10), say_hello)

Repeating Jobs

Execute a job multiple times using the Repeat class:

from rq import Repeat

# Repeat job 3 times after successful execution, with 30 second intervals
queue.enqueue(my_function, repeat=Repeat(times=3, interval=30))

Unique Jobs

Prevent duplicate jobs from being enqueued:

job = queue.enqueue(send_email, user_id, job_id='welcome-42', unique=True)

Rate Limiting

Apply concurrency-based rate limits to jobs sharing a key:

from rq import RateLimit

queue.enqueue(generate_report, rate_limit=RateLimit(key='reports', concurrency=2))

Retrying Failed Jobs

Configure jobs to retry upon failure:

from rq import Retry

# Retry up to 3 times, failed job will be requeued immediately
queue.enqueue(say_hello, retry=Retry(max=3))

Webhooks

Send HTTP requests to a URL when a job finishes or fails:

from rq import Webhook

queue.enqueue(
    say_hello,
    webhooks=[
        Webhook('https://example.com/finished', job_status='finished'),
        Webhook('https://example.com/failed', job_status='failed', method='POST'),
    ],
)

Cron Job Scheduling

RQ provides built-in functionality for interval-based and cron syntax scheduling. Define your jobs in a configuration file:

# cron_config.py
from rq import cron
from myapp import cleanup_temp_files, generate_analytics_report

cron.register(
    cleanup_temp_files,
    queue_name='maintenance',
    interval=1800  # 30 minutes in seconds
)

cron.register(
    generate_analytics_report,
    queue_name='reports',
    cron='0 8 1 * *' # Monthly report on the first day of each month at 8:00 AM
)

Then, start the rq cron command:

$ rq cron cron_config.py

The Worker

To process enqueued jobs, start an RQ worker:

$ rq worker --with-scheduler

For production, you can use rq worker-pool to run multiple worker processes:

$ rq worker-pool -n 4

Why Use RQ?

RQ stands out for its simplicity and Pythonic approach to background job processing. It offers a lightweight alternative to more complex systems, making it easy to get started while providing powerful features like job prioritization, scheduling, retries, and webhooks. Its reliance on Redis/Valkey ensures high performance and reliability, making it suitable for a wide range of asynchronous tasks, from sending emails to complex data processing.

Links

Related repositories

Similar repositories that may be relevant next.

Maskit: Local Privacy Gateway for LLMs and AI Tools

Maskit: Local Privacy Gateway for LLMs and AI Tools

September 20, 2026

Maskit is a local privacy desensitization gateway engineered for large language models and AI tools. It automatically masks sensitive data in requests sent to AI services and then seamlessly restores it in streaming responses, ensuring private information remains local. This innovative solution supports various AI assistants like Cursor and Claude Code, along with any tool offering a configurable Base URL.

data-maskingprivacyllm
CyberVerse: Self-Hosted Real-Time Digital Human Agent Platform

CyberVerse: Self-Hosted Real-Time Digital Human Agent Platform

September 18, 2026

CyberVerse is an open-source, self-hosted platform for building real-time digital human agents. It leverages WebRTC, persona memory, tools, and RAG to create voice-first AI agents, with optional digital-human video capabilities. This powerful framework allows developers to create highly interactive and lifelike AI companions.

ai-agentsdigital-humanvoice-assistant
ctx-gate: LLM Context Gateway for Efficient Token Usage

ctx-gate: LLM Context Gateway for Efficient Token Usage

September 16, 2026

ctx-gate is an LLM-agnostic context optimization proxy that reduces token consumption in AI interactions. It intelligently prunes conversation history and tool outputs, ensuring critical facts are retained without altering your workflow. Compatible with Anthropic and OpenAI APIs, ctx-gate helps developers manage LLM costs and maintain prompt fidelity.

llmcontext-managementtoken-optimization
Ferret MCP: AI-Powered Knowledge Extraction for Any Codebase

Ferret MCP: AI-Powered Knowledge Extraction for Any Codebase

September 14, 2026

Ferret MCP is an MCP server designed to extract comprehensive knowledge from any codebase, combining static analysis with AI-powered deep interpretation. It provides detailed insights into architecture, patterns, dependencies, and API surface, delivering a senior engineer's analysis in seconds. This tool integrates seamlessly with various MCP clients, offering both free static analysis and advanced AI-driven reports.

pythoncode-analysisllm

Source repository

Open the original repository on GitHub.

13 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️