Skip to main content

Provides job scheduling capabilities to RQ (Redis Queue)

Project description

RQ Scheduler

RQ Scheduler is a small package that adds job scheduling capabilities to RQ, a Redis based Python queuing library.

Requirements

Installation

You can install RQ Scheduler via pip:

pip install rq-scheduler

Usage

Schedule a job involves doing two different things: # Putting a job in the scheduler # Running a scheduler that will move scheduled jobs into queues when the time comes

Scheduling a Job

Here’s how to put a job in the scheduler:

from rq import use_connection
from rq_scheduler import Scheduler
from datetime import datetime

use_connection() # Use RQ's default Redis connection
scheduler = Scheduler() # Get a scheduler for the "default" queue

# Puts a job into the scheduler. The API is similar
# to rq except that it takes a datetime object as first argument
scheduler.schedule(datetime(2020, 01, 01, 1, 1), func)
scheduler.schedule(datetime(2025, 10, 10, 3, 4), func, foo, bar=baz)

You can also explicitly pass in connection to use a different Redis server:

from redis import Redis
from rq_scheduler import Scheduler
from datetime import datetime

scheduler = Scheduler('default', connection=Redis())
scheduler.schedule(datetime(2020, 01, 01, 1, 1), func)

Running the scheduler

RQ Scheduler comes with a script rqscheduler that runs a scheduler process that polls Redis once every minute and move scheduled jobs to the relevant queues when they need to be executed:

# This runs a scheduler process using the default Redis connection
rqscheduler

If you want to use a different Redis server you could also do:

rqscheduler --host localhost --port 6379 --db 0

The script accepts these arguments:

  • -H or --host: Redis server to connect to

  • -p or --port: port to connect to

  • -d or --db: Redis db to use

  • -P or --password: password to connect to Redis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rq-scheduler-0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file rq-scheduler-0.1.tar.gz.

File metadata

  • Download URL: rq-scheduler-0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rq-scheduler-0.1.tar.gz
Algorithm Hash digest
SHA256 71dfe58dbe2f5dc6df831b1514b2a71904b98bdf2e7ec38bfc1e2a3e4fecb723
MD5 2646bdd3514b8dfa0204e99c9946ce34
BLAKE2b-256 34479d3854eccd338155388d5c64b99036335afa6a9ab4b199ed58a0d0e4392a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page