diff --git a/src/task_manager/__about__.py b/src/task_manager/__about__.py index 0099f57..c431cf0 100644 --- a/src/task_manager/__about__.py +++ b/src/task_manager/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2024-present jefer94 # # SPDX-License-Identifier: LGPL-3.0-or-later -__version__ = "1.0.0b3" +__version__ = "1.0.0b4" diff --git a/src/task_manager/core/settings.py b/src/task_manager/core/settings.py index 0318863..56bf74f 100644 --- a/src/task_manager/core/settings.py +++ b/src/task_manager/core/settings.py @@ -1,3 +1,4 @@ +import os from datetime import timedelta from .exceptions import ProgrammingError @@ -9,8 +10,12 @@ "RETRY_AFTER": timedelta(seconds=5), "DEFAULT": 5, "SCHEDULER": 10, + "TASK_MANAGER": 6, } +if p := os.environ.get("TASK_MANAGER_PRIORITY"): + settings["TASK_MANAGER"] = int(p) + def get_setting(key, default=None): return settings.get(key, default) diff --git a/src/task_manager/django/tasks.py b/src/task_manager/django/tasks.py index f93a243..6653e2a 100644 --- a/src/task_manager/django/tasks.py +++ b/src/task_manager/django/tasks.py @@ -5,7 +5,7 @@ from celery import shared_task from django.utils import timezone -from task_manager.core.decorators import TaskPriority +from task_manager.core.settings import get_setting from .models import TaskManager @@ -15,7 +15,7 @@ # do not use our own task decorator -@shared_task(bind=False, priority=TaskPriority.TASK_MANAGER.value) +@shared_task(bind=False, priority=get_setting("TASK_MANAGER")) def mark_task_as_cancelled(task_manager_id): logger.info(f"Running mark_task_as_cancelled for {task_manager_id}")