From d6b0d19ad1f8f3d49ed110af07b2a6e52846edbc Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Tue, 29 Oct 2024 09:40:47 +0100 Subject: [PATCH] fix: refactor helper functions to avoid circular dependencies --- django_celery_results/models/generic.py | 4 ++-- django_celery_results/models/helpers.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/django_celery_results/models/generic.py b/django_celery_results/models/generic.py index e5b5da7..25c0744 100644 --- a/django_celery_results/models/generic.py +++ b/django_celery_results/models/generic.py @@ -1,7 +1,5 @@ """Database models.""" -import json - from django.utils.translation import gettext_lazy as _ from django_celery_results.models.abstract import ( @@ -25,6 +23,8 @@ class ChordCounter(AbstractChordCounter): """Chord synchronisation.""" class Meta(AbstractChordCounter.Meta): + """Table information.""" + abstract = False app_label = "django_celery_results" diff --git a/django_celery_results/models/helpers.py b/django_celery_results/models/helpers.py index 0d9da60..1338764 100644 --- a/django_celery_results/models/helpers.py +++ b/django_celery_results/models/helpers.py @@ -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: @@ -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: @@ -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: