Skip to content

Commit

Permalink
fix task manager priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Feb 17, 2024
1 parent acd4c26 commit cdbaf20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/task_manager/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present jefer94 <[email protected]>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
__version__ = "1.0.0b3"
__version__ = "1.0.0b4"
5 changes: 5 additions & 0 deletions src/task_manager/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from datetime import timedelta

from .exceptions import ProgrammingError
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/task_manager/django/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}")

Expand Down

0 comments on commit cdbaf20

Please sign in to comment.