2

I am using background_task lib in django app I am trying to execute simple function every interval (5 min) How can I set the interval

Code in views.py

@background(schedule=60)
def hello(repeat=60*5):
    print("Hello")

and I run in powershell

python manage.py process_tasks

but it not execute every 5 min I think it execute every second how can I set it??

Eman Ismail
  • 133
  • 7
  • Related: https://stackoverflow.com/q/573618/1531971 Probable duplicate: https://stackoverflow.com/q/30816134/1531971 –  Sep 20 '18 at 15:19
  • I don't get idea, background-tasks not enough to create periodic task ?? – Eman Ismail Sep 20 '18 at 15:36

1 Answers1

1

to repeat a task every 5 mins you have to pass the repeat argument when you call it not when you deff it

def hello():
    print("Hello")

hello(repeat=300)

here are the docs where you can read more about it https://django-background-tasks.readthedocs.io/en/latest/#repeating-tasks

Faiya
  • 141
  • 1
  • 8