Schedule a job to run after 30 seconds using Django-rq

310 Views Asked by At

I'm trying to implement the django-rq since I have some scraping that sometimes fails and has to be scheduled to run again after, say, 30 seconds.

As far as I understand, I push a job the queue by

django_rq.enqueue(scrape_func, foo, bar=baz)

is there a way to push it to the queue and give it

  1. A timestamp to run (like Airflow) e.g 0 01 * * *

or

  1. a time-delay before run (e.g 30 sec)
1

There are 1 best solutions below

0
Calum Mackervoy On

From the README on the GitHubPage:

With RQ 1.2.0. you can use built-in scheduler for your jobs. For example:

from django_rq.queues import get_queue

queue = get_queue('default')
job = queue.enqueue_at(datetime(2020, 10, 10), func)