0

I am trying to run a django background task every 30 seconds, as a test I'm having it print "hello", but instead of printing every 30 seconds it is printing about every second or less very quickly. Here is my code currently:

from background_task import background
from datetime import timedelta, datetime

@background(schedule=datetime.now())
def subscription_job():
    print("hello")

subscription_job(repeat=30)
  • It is working as expected. You tell it to run **now** and repeat that 30 times. Did you read [the documentation](https://django-background-tasks.readthedocs.io/en/latest/#creating-and-registering-tasks)? – Selcuk Dec 10 '19 at 01:38
  • @Selcuk ohh I see. How would I make it run in the intended way? – plastic_pearls Dec 10 '19 at 01:51
  • Use the `schedule` argument with `timedelta`. Docs are pretty clear. – Selcuk Dec 10 '19 at 04:23
  • Pretty sure this place has your answer [link](https://stackoverflow.com/questions/49536561/how-to-initialize-repeating-tasks-using-django-background-tasks) – HellaSpace Dec 11 '19 at 17:54

0 Answers0