Skip to content

Commit

Permalink
fix: refactor helper functions to avoid circular dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocastrum committed Oct 29, 2024
1 parent 10a5c3a commit d6b0d19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions django_celery_results/models/generic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Database models."""

import json

from django.utils.translation import gettext_lazy as _

from django_celery_results.models.abstract import (
Expand All @@ -25,6 +23,8 @@ class ChordCounter(AbstractChordCounter):
"""Chord synchronisation."""

class Meta(AbstractChordCounter.Meta):
"""Table information."""

abstract = False
app_label = "django_celery_results"

Expand Down
8 changes: 6 additions & 2 deletions django_celery_results/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from .generic import ChordCounter, GroupResult, TaskResult


def taskresult_model():
"""Return the TaskResult model that is active in this project."""
if not hasattr(settings, 'CELERY_RESULTS_TASKRESULT_MODEL'):
from .generic import TaskResult

return TaskResult

try:
Expand All @@ -31,6 +31,8 @@ def chordcounter_model():
"""Return the ChordCounter model that is active in this project."""

if not hasattr(settings, 'CELERY_RESULTS_CHORDCOUNTER_MODEL'):
from .generic import ChordCounter

return ChordCounter

try:
Expand All @@ -53,6 +55,8 @@ def chordcounter_model():
def groupresult_model():
"""Return the GroupResult model that is active in this project."""
if not hasattr(settings, 'CELERY_RESULTS_GROUPRESULT_MODEL'):
from .generic import GroupResult

return GroupResult

try:
Expand Down

0 comments on commit d6b0d19

Please sign in to comment.