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.
Usage
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",
args=("pm25",),
interval=300,
)
scheduler.start()
Redis keys
Keys used by this package:
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.
Development
To install pre-commit, do the following:
$ uv tool install pre-commit --with pre-commit-uv
To enable pre-commit git hooks:
$ pre-commit install
Why?
The original cron implementation in RQ is holding all the cron jobs locally as a list inside the instance of the scheduler. Because of this design choice, as soon as the scheduler is started, the list of scheduled jobs cannot be easily modified.
In some cases, we want to be able to add/edit/delete scheduled jobs on the fly and for the scheduler to acknowledge those events accordingly. This is what lead the design choices for this package.
Inspired by redisbeat, a celery scheduler using redis to store metadata. See Hello RedBeat: A New Celery Beat Scheduler for mor info.
Metadata
Release files for rq-rediscron 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rq_rediscron-0.1.10.tar.gz | 51.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rq_rediscron-0.1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 64.6 kB
Release files / rq_rediscron-0.1.10.tar.gz
| Download URL | rq_rediscron-0.1.10.tar.gz |
|---|---|
| Size | 51.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e70fc5d8c59522bcd1674d17f122abd2989d3632bc43ea09a8cf669cd3c0bd66
|
|
BLAKE2b-256 checksum How to use checksums |
cacb0eb65097285d6e92880a05cb24204e90a5855669192090e70946b710a72c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / rq_rediscron-0.1.10-py3-none-any.whl
| Download URL | rq_rediscron-0.1.10-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
349872f7915017e88adecab3c7f0181edbd03a60af1e9942f9fbf27b172a77fa
|
|
BLAKE2b-256 checksum How to use checksums |
38d13586fbc83e85bd79cfb1a95c1537812dfad1d36e5a3c56d6f8bc46b235c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for rq-rediscron 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.