Skip to main content

Redis-backed runtime-editable cron scheduler for RQ

Project description

rq-rediscron

rq-rediscron provides Redis-backed subclasses for RQ cron scheduling:

  • RedisCronJob
  • RedisCronScheduler

Cron job definitions are stored in Redis hashes and indexed in a sorted set by next enqueue time. This lets scheduler processes pick up job creates, edits, and deletes at runtime without restart.

Only one RedisCronScheduler process runs at a time. The scheduler acquires rq:cron_jobs:lock during register_birth(), extends that lock on heartbeat, and releases it during register_death(). A second scheduler can start after the lock TTL expires, which provides failover without duplicate enqueue loops.

from redis import Redis
from rediscron import RedisCronScheduler


def rebuild_metric(metric_id: str) -> None:
    ...


connection = Redis.from_url("redis://localhost:6379/0")
scheduler = RedisCronScheduler(connection)
scheduler.register(
    rebuild_metric,
    queue_name="metrics",
    id="metric:pm25",
    args=("pm25",),
    interval=300,
)
scheduler.start()

Redis keys:

  • rq:cron_job:{id} stores one cron job hash.
  • rq:cron_jobs indexes job ids by next enqueue timestamp.
  • rq:cron_jobs:lock allows one live scheduler process at a time.
  • rq:cron_jobs:last_update records runtime changes.
  • rq:cron_jobs:events publishes create, update, and delete events.

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_rediscron-0.1.3.tar.gz (46.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rq_rediscron-0.1.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file rq_rediscron-0.1.3.tar.gz.

File metadata

  • Download URL: rq_rediscron-0.1.3.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rq_rediscron-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cef6d7aea6694fc33b124a48f6cab66c417e2eb1b1080f2c13bb0c9ed7df7dba
MD5 adae2aa14500e5788cd8bcbde5ba1484
BLAKE2b-256 bc0fd47b86b72edb87f5739802c8b39d5081762fb3cf9bc62cecc7f3dd693b90

See more details on using hashes here.

File details

Details for the file rq_rediscron-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rq_rediscron-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rq_rediscron-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9772b86d21e91c38c45c748d9c88db90615eb6c1fb7d32d9b756be4f689ef3c0
MD5 07977fe50bf379e3b6b7975fccef5f95
BLAKE2b-256 5b1a5a9503a8ed79eb20507f96dee0b6c2aecc701cbb7c098dfa84c8a1305cd6

See more details on using hashes here.

Supported by

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