astrosat / django-astrosat-tasks

Common backend library for Astrosat projects' task brokering
GNU General Public License v3.0
0 stars 0 forks source link

add support for enable_celery setting #2

Open allynt opened 4 years ago

allynt commented 4 years ago

started writing this code:

import functools
from .conf import app_settings

def conditional_task(task_fn):
    @functools.wraps(task_fn)
    def conditional_task_wrapper(*args, **kwargs):
        if not app_settings.ASTROSAT_TASKS_ENABLE_CELERY:
            return None
        task_fn(*args, **kwargs)
    return conditional_task_wrapper

But noted that the task still ran, it just didn't do anything if ASTROSAT_TASKS_ENABLE_CELERY was False.


Instead I can use a post_save signal on TaskSettings to somehow trigger disabling celery... maybe by re-configuring the celery app?

allynt commented 4 years ago

This is too f#@$ng! hard for now. I can just disable periodic tasks explicitly in the db and not run tasks manually via the management command and API.