Eman Ismail
Eman Ismail

Reputation: 133

Django Background-tasks interval

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??

Upvotes: 2

Views: 2260

Answers (1)

Faiya
Faiya

Reputation: 151

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

Upvotes: 1

Related Questions