diff --git a/celery_haystack/apps.py b/celery_haystack/apps.py new file mode 100644 index 0000000..e0031c7 --- /dev/null +++ b/celery_haystack/apps.py @@ -0,0 +1,6 @@ +from .conf import CeleryHaystack # this populates our settings +from django.apps import AppConfig + + +class CeleryHaystackAppConfig(AppConfig): + name = "celery_haystack" diff --git a/celery_haystack/conf.py b/celery_haystack/conf.py index 5af93a4..ab76c78 100644 --- a/celery_haystack/conf.py +++ b/celery_haystack/conf.py @@ -20,6 +20,8 @@ class CeleryHaystack(AppConf): QUEUE = None #: Whether the task should be handled transaction safe TRANSACTION_SAFE = True + #: Whether the task shoild ignore results + IGNORE_RESULTS = False #: The batch size used by the CeleryHaystackUpdateIndex task COMMAND_BATCH_SIZE = None diff --git a/celery_haystack/indexes.py b/celery_haystack/indexes.py index 07dbf90..c4499a1 100644 --- a/celery_haystack/indexes.py +++ b/celery_haystack/indexes.py @@ -2,4 +2,4 @@ class CelerySearchIndex(indexes.SearchIndex): - pass + task_path = None diff --git a/celery_haystack/signals.py b/celery_haystack/signals.py index f952f99..682221f 100644 --- a/celery_haystack/signals.py +++ b/celery_haystack/signals.py @@ -41,4 +41,4 @@ def enqueue(self, action, instance, sender, **kwargs): if isinstance(index, CelerySearchIndex): if action == 'update' and not index.should_update(instance): continue - enqueue_task(action, instance) + enqueue_task(action, instance, task_path=index.task_path) diff --git a/celery_haystack/tasks.py b/celery_haystack/tasks.py index 20f798a..1defd8b 100644 --- a/celery_haystack/tasks.py +++ b/celery_haystack/tasks.py @@ -19,6 +19,7 @@ class CeleryHaystackSignalHandler(Task): using = settings.CELERY_HAYSTACK_DEFAULT_ALIAS max_retries = settings.CELERY_HAYSTACK_MAX_RETRIES default_retry_delay = settings.CELERY_HAYSTACK_RETRY_DELAY + ignore_result = settings.CELERY_HAYSTACK_IGNORE_RESULTS def split_identifier(self, identifier, **kwargs): """ diff --git a/celery_haystack/utils.py b/celery_haystack/utils.py index 855c66c..f3fc202 100644 --- a/celery_haystack/utils.py +++ b/celery_haystack/utils.py @@ -38,7 +38,8 @@ def enqueue_task(action, instance, **kwargs): if settings.CELERY_HAYSTACK_COUNTDOWN: options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN - task = get_update_task() + task_path = kwargs.get('task_path', None) + task = get_update_task(task_path=task_path) def task_func(): return task.apply_async((action, identifier), kwargs, **options)