API Reference

RQ

A simple Python library for background jobs backed by Redis, with queues and worker processes.

Official Documentation ↗
CompatibilityThis documentation covers version v3.0.0. Check the official docs for the latest API surface.

Installation

pippip install rq

Methods

RQ enqueues function calls into Redis queues and worker processes execute them out of band.

Key Features

  • Simple enqueue of any function
  • Retries and scheduled jobs
  • Worker pools and dashboards

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The official API reference declares the following error types:

  • DuplicateJobError (exception(rq.exceptions 模块导出,unique 任务重复入队时抛出)) — official text: “from rq.exceptions import DuplicateJobError queue = Queue(connection=Redis()) # First enqueue succeeds job = queue.enqueue(send_welcome_email, user_id, job_id=‘welcome-email-42’, unique=True) # Attempting to enqueue again with the same job_id raises DuplicateJ” (source: https://python-rq.org/docs/, fetched 2026-11-08T19:58:23+08:00)

Security

Official security statements captured from the package documentation:

  • 默认 pickle 序列化不安全,仅对接可信 Redis — “Warning: RQ uses pickle as its default serializer, which is not secure . Only run RQ against Redis instances that you trust. It is possible to construct malicious pickle data that will execute arbitrary code during unpickling.” (source: https://python-rq.org/docs/workers/, fetched 2026-11-08T19:58:23+08:00)

API reference evidence

Fetched from official sources on 2026-11-08T19:58:23+08:00 via WebFetch https://python-rq.org/docs/;WebFetch https://python-rq.org/docs/workers/.

  • rq.Queue → signature from https://python-rq.org/docs/; official text: “If you want to put the work on a specific queue, simply specify its name: q = Queue('low', connection=redis_conn) q.enqueue(count_words_at_url, 'http://nvie.com') Notice the Queue('low') in the example above? Y”
  • queue.enqueue → signature from https://python-rq.org/docs/; official text: “redis_conn = Redis() q = Queue(connection=redis_conn) # no args implies the default queue # Delay execution of count_words_at_url(‘http://nvie.com’) job = q.enqueue(count_words_at_url, ‘http://nvie.com’)”
  • rq.Worker → signature from https://python-rq.org/docs/workers/; official text: “from redis import Redis from rq import Worker # Preload libraries import library_that_you_want_preloaded # Provide the worker with the list of queues (str) to listen to. w = Worker([‘default’], connection=Redis()) w.work”

FAQ

How do retries work?
Pass Retry(max=3, interval=[10, 30, 60]) when enqueuing, or configure it on the queue so transient failures are retried.
Can jobs be scheduled?
Yes. Use enqueue_in with a timedelta or a scheduler to run jobs at a future time.
What if a worker crashes?
The job is requeued after its timeout, so handlers must be idempotent because they may run more than once.