# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-rq-scheduler VERSION= 0.13.1 KEYWORDS= python VARIANTS= v11 v12 SDESC[v11]= Job scheduling capabilities to Redis Queue (3.11) SDESC[v12]= Job scheduling capabilities to Redis Queue (3.12) HOMEPAGE= https://github.com/rq/rq-scheduler CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/df/27/27876b5b285552030134494406adb93eceb3d0e1cac6e75d49ff1f16af56 DISTFILE[1]= rq_scheduler-0.13.1-py2.py3-none-any.whl:main DF_INDEX= 1 SPKGS[v11]= single SPKGS[v12]= single OPTIONS_AVAILABLE= PY311 PY312 OPTIONS_STANDARD= none VOPTS[v11]= PY311=ON PY312=OFF VOPTS[v12]= PY311=OFF PY312=ON USES= shebangfix DISTNAME= rq_scheduler-0.13.1.dist-info SHEBANG_FILES= stage{{PYTHON_SITELIBDIR}}/rq_scheduler/scripts/rqscheduler.py GENERATED= yes [PY311].RUN_DEPENDS_ON= python-crontab:single:v11 python-rq:single:v11 python-python-dateutil:single:v11 python-freezegun:single:v11 [PY311].USES_ON= python:v11,wheel [PY312].RUN_DEPENDS_ON= python-crontab:single:v12 python-rq:single:v12 python-python-dateutil:single:v12 python-freezegun:single:v12 [PY312].USES_ON= python:v12,wheel [FILE:2840:descriptions/desc.single] ============ RQ Scheduler ============ [RQ Scheduler] is a small package that adds job scheduling capabilities to [RQ], a [Redis] based Python queuing library. ==================== Support RQ Scheduler ==================== If you find ``rq-scheduler`` useful, please consider supporting its development via [Tidelift]. ============ Requirements ============ * `RQ`_ ============ Installation ============ You can install `RQ Scheduler`_ via pip:: pip install rq-scheduler Or you can download the latest stable package from [PyPI]. ===== Usage ===== Schedule a job involves doing two different things: 1. Putting a job in the scheduler 2. Running a scheduler that will move scheduled jobs into queues when the time comes ---------------- Scheduling a Job ---------------- There are two ways you can schedule a job. The first is using RQ Scheduler's enqueue_at .. code-block:: python from redis import Redis from rq import Queue from rq_scheduler import Scheduler from datetime import datetime scheduler = Scheduler(connection=Redis()) # Get a scheduler for the "default" queue scheduler = Scheduler('foo', connection=Redis()) # Get a scheduler for the "foo" queue # You can also instantiate a Scheduler using an RQ Queue queue = Queue('bar', connection=Redis()) scheduler = Scheduler(queue=queue, connection=queue.connection) # Puts a job into the scheduler. The API is similar to RQ except that it # takes a datetime object as first argument. So for example to schedule a # job to run on Jan 1st 2020 we do: scheduler.enqueue_at(datetime(2020, 1, 1), func) # Date time should be in UTC # Here's another example scheduling a job to run at a specific date and time (in UTC), # complete with args and kwargs. scheduler.enqueue_at(datetime(2020, 1, 1, 3, 4), func, foo, bar=baz) # You can choose the queue type where jobs will be enqueued by passing the name of the type to the scheduler # used to enqueue scheduler = Scheduler('foo', queue_class="rq.Queue") scheduler.enqueue_at(datetime(2020, 1, 1), func) # The job will be enqueued at the queue named "foo" using the queue type "rq.Queue" The second way is using enqueue_in. Instead of taking a datetime object, this method expects a timedelta and schedules the job to run at X seconds/minutes/hours/days/weeks later. For example, if we want to monitor how popular a tweet is a few times during the course of the day, we could do something like .. code-block:: python from datetime import timedelta # Schedule a job to run 10 minutes, 1 hour and 1 day later scheduler.enqueue_in(timedelta(minutes=10), count_retweets, tweet_id) scheduler.enqueue_in(timedelta(hours=1), count_retweets, tweet_id) scheduler.enqueue_in(timedelta(days=1), count_retweets, tweet_id) [FILE:119:distinfo] c2b19c3aedfc7de4d405183c98aa327506e423bf4cdc556af55aaab9bbe5d1a1 13854 rq_scheduler-0.13.1-py2.py3-none-any.whl