'Run periodic celery task with a dynamic schedule in django application

I am wondering if it is possible to have my end users dynamically adjust the schedule of a periodic task.

So something along these lines:

# celery.py

def get_schedule():
    config = get_user_config()  # returns a model object of sorts
    return config.frequency_in_seconds

app.conf.beat_schedule = {
    'my_periodic_task': {
        'task': 'my_periodic_task',
        'schedule': get_schedule,  # schedule updated based on `get_schedule` function
    },
}

This way, if a user were to change the frequency_in_seconds field in their user config setting, it would dynamically update the beat schedule.

My preference would be to do this outside of the Django Admin site and without any additional packages (e.g. django-celery-beat).

Any thoughts or ideas would be much appreciated.

Thanks



Solution 1:[1]

If you're using django, you can use django-celery-beat to allow end-users to control the schedule using the django admin panel.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 2ps