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.2.tar.gz (12.4 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.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rq_rediscron-0.1.2.tar.gz
  • Upload date:
  • Size: 12.4 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.2.tar.gz
Algorithm Hash digest
SHA256 a709df3a8d84b906f8b2a7ae6e5bf53dc9b3ca2ed7145a638d1a6ca0b95f07c3
MD5 f67eb9ca89619cc237924444d29a609d
BLAKE2b-256 1e6e77beb825ce82825083ebc76c87b701123385c8eefb205aaf91487946f7e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rq_rediscron-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7362658bf82c92d38e1e171f2a426dc0272ca24ff8f248dff81e2206032c3f9
MD5 db34cbe65b1738f4c23b5371c0265959
BLAKE2b-256 7c58c59d07cc9727acd8fd901b983942e1c6a0cdd31f9374dc364416a8e6e0ec

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