![]() ![]() Periodic & Repeated JobsĪs of version 0.3, RQ Scheduler also supports creating periodic and repeated jobs. IMPORTANT: You should always use UTC datetime when working with RQ Scheduler. enqueue_in ( timedelta ( days = 1 ), count_retweets, tweet_id ) enqueue_in ( timedelta ( hours = 1 ), count_retweets, tweet_id ) scheduler. enqueue_in ( timedelta ( minutes = 10 ), count_retweets, tweet_id ) scheduler. Popular a tweet is a few times during the course of the day, we could do something like from datetime import timedelta # Schedule a job to run 10 minutes, 1 hour and 1 day later scheduler. ![]() X seconds/minutes/hours/days/weeks later. This method expects a timedelta and schedules the job to run at 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. So for example to schedule a # job to run on Jan 1st 2020 we do: scheduler. ![]() The API is similar to RQ except that it # takes a datetime object as first argument. The first is using RQ Scheduler’s enqueue_at 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 # You can also instantiate a Scheduler using an RQ Queue queue = Queue ( 'foo', connection = Redis ()) scheduler = Scheduler ( queue = queue ) # Puts a job into the scheduler. There are two ways you can schedule a job. Running a scheduler that will move scheduled jobs into queues when the time comes Schedule a job involves doing two different things: Or you can download the latest stable package from PyPI. You can install RQ Scheduler via pip: pip install rq-scheduler ![]()
0 Comments
Leave a Reply. |