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.4.tar.gz (46.7 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.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rq_rediscron-0.1.4.tar.gz
  • Upload date:
  • Size: 46.7 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.4.tar.gz
Algorithm Hash digest
SHA256 52bf75770a955fa39695f59de323715d2c3acbc3ae6eb295f5a1344d79235859
MD5 6f07e42ab15e869cc226269fcedeefd5
BLAKE2b-256 d425a846e710b0fdd60c8119e1e8e37137fa7c07f45048a48eafb7efe582cd14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rq_rediscron-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ed73fffbf02a96312a694e8d1be74e6664a5c80978e5909657cec0072d9f460a
MD5 7f59ea1614dfd4b1d42a54f3ba22fcc7
BLAKE2b-256 1293a110d5bfb9bfe0f2c95ddfc0e177cf5f0091e608e3ae7d3c58f4a86e9d51

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