Django Q2 - Setting Up A Basic Structure For Function Scheduling

53 Views Asked by At

I'm kind of new to using Django different then its basic scope. I scheduled a function that works every minute for trial purposes. I read the documentation many times it is still obscure for me that what is the right way of using the Django Q2 library for scheduling.

Can you please provide a clarification for me. Note that, I'm using DjangoORM.

In my attempt, I created schedule.py as below script and make it work somehow but I'm not sure what is the correct way to run 'setup_periodic_tasks'. Furthermore, earlier tasks that I run are still showing up everytime I run qcluster despite I deleted them from the Tasks object, so how can I delete them for good?

def schedule_price_list_status():
    print('PRICE LIST SCHEDULED')

def setup_periodic_tasks(**kwargs):
    print('SETUP TASKS')
    schedule('my_app.schedules.schedule_price_list_status', schedule_type='I', repeats=2, minutes=1)

setup_periodic_tasks()
0

There are 0 best solutions below