Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate Task/Queue for SearchIndex #59 #60

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions celery_haystack/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .conf import CeleryHaystack # this populates our settings
from django.apps import AppConfig


class CeleryHaystackAppConfig(AppConfig):
name = "celery_haystack"
2 changes: 2 additions & 0 deletions celery_haystack/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion celery_haystack/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CelerySearchIndex(indexes.SearchIndex):
pass
task_path = None
2 changes: 1 addition & 1 deletion celery_haystack/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions celery_haystack/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
3 changes: 2 additions & 1 deletion celery_haystack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down