New Upstream Release - celery-haystack-ng

Ready changes

Summary

Merged new upstream version: 2.0 (was: 0.20.post2).

Resulting package

Built on 2023-01-11T02:28 (took 6m12s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases python3-celery-haystack-ng

Lintian Result

Diff

diff --git a/PKG-INFO b/PKG-INFO
index e4b537a..047b2b9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,105 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: celery-haystack-ng
-Version: 0.20.post2
+Version: 2.0
 Summary: An app for integrating Celery with Haystack
 Home-page: http://celery-haystack-ng.rtfd.org/
 Author: Dominik George
 Author-email: dominik.george@teckids.org
 License: UNKNOWN
-Description: ==================
-        celery-haystack-ng
-        ==================
-        
-        This Django app allows you to utilize Celery for automatically updating and
-        deleting objects in a Haystack_ search index.
-        
-        Forked from the original celery-haystack_.
-        
-        Requirements
-        ------------
-        
-        * Django 2.1+
-        * Haystack_ 2.X+
-        * Celery_ 4.X+
-        
-        You also need to install your choice of one of the supported search engines
-        for Haystack and one of the supported backends for Celery.
-        
-        
-        .. _Haystack: http://haystacksearch.org
-        .. _celery-haystack: https://github.com/django-haystack/celery-haystack
-        
-        
-        Installation
-        ------------
-        
-        Use your favorite Python package manager to install the app from PyPI, e.g.::
-        
-            pip install celery-haystack-ng
-        
-        
-        For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
-        brings transaction commit hooks to Django.
-        
-        .. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
-        
-        
-        Usage
-        -----
-        
-        1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
-        
-           .. code:: python
-        
-             INSTALLED_APPS = [
-                 # ..
-                 'celery_haystack',
-             ]
-        
-        2. Enable the celery-haystack signal processor in the settings
-        
-           .. code:: python
-        
-            HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
-        
-        3. Alter all of your ``SearchIndex`` subclasses to inherit from
-           ``celery_haystack.indexes.CelerySearchIndex`` and
-           ``haystack.indexes.Indexable``
-        
-           .. code:: python
-        
-             from haystack import indexes
-             from celery_haystack.indexes import CelerySearchIndex
-             from myapp.models import Note
-        
-             class NoteIndex(CelerySearchIndex, indexes.Indexable):
-                 text = indexes.CharField(document=True, model_attr='content')
-        
-                 def get_model(self):
-                     return Note
-        
-        4. Ensure your Celery instance is running.
-        
-        Thanks
-        ------
-        
-        This app is a blatant rip-off of Daniel Lindsley's queued_search_
-        app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
-        queues_ library by Matt Croyden.
-        
-        .. _queued_search: https://github.com/toastdriven/queued_search/
-        .. _Celery: http://celeryproject.org/
-        .. _queues: http://code.google.com/p/queues/
-        
-        Issues
-        ------
-        
-        Please use the `EduGit issue tracker`_ for any bug reports or feature
-        requests.
-        
-        .. _`EduGit issue tracker`: https://edugit.org/AlekSIS/libs/celery-haystack-ng/-/issues
-        
-        
 Platform: UNKNOWN
 Classifier: Development Status :: 4 - Beta
 Classifier: Environment :: Web Environment
@@ -109,3 +15,101 @@ Classifier: License :: OSI Approved :: BSD License
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Utilities
+License-File: LICENSE
+License-File: AUTHORS
+
+==================
+celery-haystack-ng
+==================
+
+This Django app allows you to utilize Celery for automatically updating and
+deleting objects in a Haystack_ search index.
+
+Forked from the original celery-haystack_.
+
+Requirements
+------------
+
+* Django 2.1+
+* Haystack_ 2.X+
+* Celery_ 4.X+
+
+You also need to install your choice of one of the supported search engines
+for Haystack and one of the supported backends for Celery.
+
+
+.. _Haystack: http://haystacksearch.org
+.. _celery-haystack: https://github.com/django-haystack/celery-haystack
+
+
+Installation
+------------
+
+Use your favorite Python package manager to install the app from PyPI, e.g.::
+
+    pip install celery-haystack-ng
+
+
+For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
+brings transaction commit hooks to Django.
+
+.. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
+
+
+Usage
+-----
+
+1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
+
+   .. code:: python
+
+     INSTALLED_APPS = [
+         # ..
+         'celery_haystack',
+     ]
+
+2. Enable the celery-haystack signal processor in the settings
+
+   .. code:: python
+
+    HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
+
+3. Alter all of your ``SearchIndex`` subclasses to inherit from
+   ``celery_haystack.indexes.CelerySearchIndex`` and
+   ``haystack.indexes.Indexable``
+
+   .. code:: python
+
+     from haystack import indexes
+     from celery_haystack.indexes import CelerySearchIndex
+     from myapp.models import Note
+
+     class NoteIndex(CelerySearchIndex, indexes.Indexable):
+         text = indexes.CharField(document=True, model_attr='content')
+
+         def get_model(self):
+             return Note
+
+4. Ensure your Celery instance is running.
+
+Thanks
+------
+
+This app is a blatant rip-off of Daniel Lindsley's queued_search_
+app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
+queues_ library by Matt Croyden.
+
+.. _queued_search: https://github.com/toastdriven/queued_search/
+.. _Celery: http://celeryproject.org/
+.. _queues: http://code.google.com/p/queues/
+
+Issues
+------
+
+Please use the `EduGit issue tracker`_ for any bug reports or feature
+requests.
+
+.. _`EduGit issue tracker`: https://edugit.org/AlekSIS/libs/celery-haystack-ng/-/issues
+
+
+
diff --git a/celery_haystack/__init__.py b/celery_haystack/__init__.py
index d0ecbd7..0a990c1 100644
--- a/celery_haystack/__init__.py
+++ b/celery_haystack/__init__.py
@@ -1,4 +1,4 @@
-__version__ = '0.20.post2'
+__version__ = '2.0'
 
 
 def version_hook(config):
diff --git a/celery_haystack/conf.py b/celery_haystack/conf.py
index c88c488..7704901 100644
--- a/celery_haystack/conf.py
+++ b/celery_haystack/conf.py
@@ -55,11 +55,4 @@ class CeleryHaystack(AppConf):
         return data
 
 
-signal_processor = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR', None)
-
-
-if signal_processor is None:
-    raise ImproperlyConfigured("When using celery-haystack with Haystack 2.X "
-                               "the HAYSTACK_SIGNAL_PROCESSOR setting must be "
-                               "set. Use 'celery_haystack.signals."
-                               "CelerySignalProcessor' as default.")
+signal_processor = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR', "celery_haystack.signals.CelerySignalProcessor")
diff --git a/celery_haystack/signals.py b/celery_haystack/signals.py
index f952f99..f37e704 100644
--- a/celery_haystack/signals.py
+++ b/celery_haystack/signals.py
@@ -1,28 +1,41 @@
+from django.db import transaction
 from django.db.models import signals
 
-from haystack.signals import BaseSignalProcessor
+from haystack.signals import RealtimeSignalProcessor
 from haystack.exceptions import NotHandled
+from haystack.utils import get_identifier
 
-from .utils import enqueue_task
+from .conf import settings
+from .utils import get_update_task
 from .indexes import CelerySearchIndex
 
 
-class CelerySignalProcessor(BaseSignalProcessor):
+class CelerySignalProcessor(RealtimeSignalProcessor):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self._queue = []
+        self._on_commit_registered = False
 
-    def setup(self):
-        signals.post_save.connect(self.enqueue_save)
-        signals.post_delete.connect(self.enqueue_delete)
-
-    def teardown(self):
-        signals.post_save.disconnect(self.enqueue_save)
-        signals.post_delete.disconnect(self.enqueue_delete)
-
-    def enqueue_save(self, sender, instance, **kwargs):
+    def handle_save(self, sender, instance, **kwargs):
         return self.enqueue('update', instance, sender, **kwargs)
 
-    def enqueue_delete(self, sender, instance, **kwargs):
+    def handle_delete(self, sender, instance, **kwargs):
         return self.enqueue('delete', instance, sender, **kwargs)
 
+    def run_task(self):
+        options = {}
+        if settings.CELERY_HAYSTACK_QUEUE:
+            options['queue'] = settings.CELERY_HAYSTACK_QUEUE
+        if settings.CELERY_HAYSTACK_COUNTDOWN:
+            options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN
+
+        if self._queue:
+            task = get_update_task()
+            task.apply_async((self._queue,), {}, **options)
+
+            self._queue = []
+
+
     def enqueue(self, action, instance, sender, **kwargs):
         """
         Given an individual model instance, determine if a backend
@@ -41,4 +54,7 @@ class CelerySignalProcessor(BaseSignalProcessor):
             if isinstance(index, CelerySearchIndex):
                 if action == 'update' and not index.should_update(instance):
                     continue
-                enqueue_task(action, instance)
+                self._queue.append((action, get_identifier(instance)))
+
+                if not self._on_commit_registered:
+                    transaction.on_commit(self.run_task)
diff --git a/celery_haystack/tasks.py b/celery_haystack/tasks.py
index 1d6b06d..fbfa03d 100644
--- a/celery_haystack/tasks.py
+++ b/celery_haystack/tasks.py
@@ -13,6 +13,7 @@ from celery.utils.log import get_task_logger
 logger = get_task_logger(__name__)
 
 
+@current_app.register_task
 class CeleryHaystackSignalHandler(current_app.Task):
     name = "haystack_signal_handler"
     using = settings.CELERY_HAYSTACK_DEFAULT_ALIAS
@@ -81,7 +82,12 @@ class CeleryHaystackSignalHandler(current_app.Task):
             raise ImproperlyConfigured("Couldn't find a SearchIndex for %s." %
                                        model_class)
 
-    def run(self, action, identifier, **kwargs):
+    def run(self, queue, **kwargs):
+        """Trigger actual index handler for a list of actions."""
+        for action, identifier in queue:
+            self._run_one(action, identifier)
+
+    def _run_one(self, action, identifier, **kwargs):
         """
         Trigger the actual index handler depending on the
         given action ('update' or 'delete').
@@ -135,6 +141,7 @@ class CeleryHaystackSignalHandler(current_app.Task):
                 raise ValueError("Unrecognized action %s" % action)
 
 
+@current_app.register_task
 class CeleryHaystackUpdateIndex(current_app.Task):
     """
     A celery task class to be used to call the update_index management
@@ -158,7 +165,3 @@ class CeleryHaystackUpdateIndex(current_app.Task):
         logger.info("Starting update index")
         call_command('update_index', *apps, **defaults)
         logger.info("Finishing update index")
-
-
-current_app.tasks.register(CeleryHaystackSignalHandler)
-current_app.tasks.register(CeleryHaystackUpdateIndex)
diff --git a/celery_haystack/utils.py b/celery_haystack/utils.py
index 9cb4938..cc1f92d 100644
--- a/celery_haystack/utils.py
+++ b/celery_haystack/utils.py
@@ -3,9 +3,6 @@ try:
     from importlib import import_module
 except ImportError:
     from django.utils.importlib import import_module
-from django.db import connection, transaction
-
-from haystack.utils import get_identifier
 
 from .conf import settings
 
@@ -19,37 +16,8 @@ def get_update_task(task_path=None):
         raise ImproperlyConfigured('Error importing module %s: "%s"' %
                                    (module, e))
     try:
-        Task = getattr(mod, attr)
+        task = getattr(mod, attr)
     except AttributeError:
         raise ImproperlyConfigured('Module "%s" does not define a "%s" '
                                    'class.' % (module, attr))
-    return Task()
-
-
-def enqueue_task(action, instance, **kwargs):
-    """
-    Common utility for enqueing a task for the given action and
-    model instance.
-    """
-    identifier = get_identifier(instance)
-    options = {}
-    if settings.CELERY_HAYSTACK_QUEUE:
-        options['queue'] = settings.CELERY_HAYSTACK_QUEUE
-    if settings.CELERY_HAYSTACK_COUNTDOWN:
-        options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN
-
-    task = get_update_task()
-    task_func = lambda: task.apply_async((action, identifier), kwargs, **options)
-
-    if hasattr(transaction, 'on_commit'):
-        # Django 1.9 on_commit hook
-        transaction.on_commit(
-            task_func
-        )
-    elif hasattr(connection, 'on_commit'):
-        # Django-transaction-hooks
-        connection.on_commit(
-            task_func
-        )
-    else:
-        task_func()
+    return task
diff --git a/celery_haystack_ng.egg-info/PKG-INFO b/celery_haystack_ng.egg-info/PKG-INFO
index e4b537a..047b2b9 100644
--- a/celery_haystack_ng.egg-info/PKG-INFO
+++ b/celery_haystack_ng.egg-info/PKG-INFO
@@ -1,105 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: celery-haystack-ng
-Version: 0.20.post2
+Version: 2.0
 Summary: An app for integrating Celery with Haystack
 Home-page: http://celery-haystack-ng.rtfd.org/
 Author: Dominik George
 Author-email: dominik.george@teckids.org
 License: UNKNOWN
-Description: ==================
-        celery-haystack-ng
-        ==================
-        
-        This Django app allows you to utilize Celery for automatically updating and
-        deleting objects in a Haystack_ search index.
-        
-        Forked from the original celery-haystack_.
-        
-        Requirements
-        ------------
-        
-        * Django 2.1+
-        * Haystack_ 2.X+
-        * Celery_ 4.X+
-        
-        You also need to install your choice of one of the supported search engines
-        for Haystack and one of the supported backends for Celery.
-        
-        
-        .. _Haystack: http://haystacksearch.org
-        .. _celery-haystack: https://github.com/django-haystack/celery-haystack
-        
-        
-        Installation
-        ------------
-        
-        Use your favorite Python package manager to install the app from PyPI, e.g.::
-        
-            pip install celery-haystack-ng
-        
-        
-        For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
-        brings transaction commit hooks to Django.
-        
-        .. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
-        
-        
-        Usage
-        -----
-        
-        1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
-        
-           .. code:: python
-        
-             INSTALLED_APPS = [
-                 # ..
-                 'celery_haystack',
-             ]
-        
-        2. Enable the celery-haystack signal processor in the settings
-        
-           .. code:: python
-        
-            HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
-        
-        3. Alter all of your ``SearchIndex`` subclasses to inherit from
-           ``celery_haystack.indexes.CelerySearchIndex`` and
-           ``haystack.indexes.Indexable``
-        
-           .. code:: python
-        
-             from haystack import indexes
-             from celery_haystack.indexes import CelerySearchIndex
-             from myapp.models import Note
-        
-             class NoteIndex(CelerySearchIndex, indexes.Indexable):
-                 text = indexes.CharField(document=True, model_attr='content')
-        
-                 def get_model(self):
-                     return Note
-        
-        4. Ensure your Celery instance is running.
-        
-        Thanks
-        ------
-        
-        This app is a blatant rip-off of Daniel Lindsley's queued_search_
-        app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
-        queues_ library by Matt Croyden.
-        
-        .. _queued_search: https://github.com/toastdriven/queued_search/
-        .. _Celery: http://celeryproject.org/
-        .. _queues: http://code.google.com/p/queues/
-        
-        Issues
-        ------
-        
-        Please use the `EduGit issue tracker`_ for any bug reports or feature
-        requests.
-        
-        .. _`EduGit issue tracker`: https://edugit.org/AlekSIS/libs/celery-haystack-ng/-/issues
-        
-        
 Platform: UNKNOWN
 Classifier: Development Status :: 4 - Beta
 Classifier: Environment :: Web Environment
@@ -109,3 +15,101 @@ Classifier: License :: OSI Approved :: BSD License
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Utilities
+License-File: LICENSE
+License-File: AUTHORS
+
+==================
+celery-haystack-ng
+==================
+
+This Django app allows you to utilize Celery for automatically updating and
+deleting objects in a Haystack_ search index.
+
+Forked from the original celery-haystack_.
+
+Requirements
+------------
+
+* Django 2.1+
+* Haystack_ 2.X+
+* Celery_ 4.X+
+
+You also need to install your choice of one of the supported search engines
+for Haystack and one of the supported backends for Celery.
+
+
+.. _Haystack: http://haystacksearch.org
+.. _celery-haystack: https://github.com/django-haystack/celery-haystack
+
+
+Installation
+------------
+
+Use your favorite Python package manager to install the app from PyPI, e.g.::
+
+    pip install celery-haystack-ng
+
+
+For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
+brings transaction commit hooks to Django.
+
+.. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
+
+
+Usage
+-----
+
+1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
+
+   .. code:: python
+
+     INSTALLED_APPS = [
+         # ..
+         'celery_haystack',
+     ]
+
+2. Enable the celery-haystack signal processor in the settings
+
+   .. code:: python
+
+    HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
+
+3. Alter all of your ``SearchIndex`` subclasses to inherit from
+   ``celery_haystack.indexes.CelerySearchIndex`` and
+   ``haystack.indexes.Indexable``
+
+   .. code:: python
+
+     from haystack import indexes
+     from celery_haystack.indexes import CelerySearchIndex
+     from myapp.models import Note
+
+     class NoteIndex(CelerySearchIndex, indexes.Indexable):
+         text = indexes.CharField(document=True, model_attr='content')
+
+         def get_model(self):
+             return Note
+
+4. Ensure your Celery instance is running.
+
+Thanks
+------
+
+This app is a blatant rip-off of Daniel Lindsley's queued_search_
+app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
+queues_ library by Matt Croyden.
+
+.. _queued_search: https://github.com/toastdriven/queued_search/
+.. _Celery: http://celeryproject.org/
+.. _queues: http://code.google.com/p/queues/
+
+Issues
+------
+
+Please use the `EduGit issue tracker`_ for any bug reports or feature
+requests.
+
+.. _`EduGit issue tracker`: https://edugit.org/AlekSIS/libs/celery-haystack-ng/-/issues
+
+
+
diff --git a/debian/changelog b/debian/changelog
index 29ca846..79534ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,11 @@
-celery-haystack-ng (0.20.post2-2) UNRELEASED; urgency=medium
+celery-haystack-ng (2.0-1) UNRELEASED; urgency=medium
 
   * Use secure URI in debian/watch.
   * Set debhelper-compat version in Build-Depends.
   * Update standards version to 4.6.2, no changes needed.
+  * New upstream release.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sun, 08 Jan 2023 22:18:12 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 Jan 2023 02:23:00 -0000
 
 celery-haystack-ng (0.20.post2-1) unstable; urgency=low
 

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-2.0.egg-info/PKG-INFO
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-2.0.egg-info/dependency_links.txt
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-2.0.egg-info/not-zip-safe
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-2.0.egg-info/requires.txt
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-2.0.egg-info/top_level.txt

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-0.20.post2.egg-info/PKG-INFO
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-0.20.post2.egg-info/dependency_links.txt
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-0.20.post2.egg-info/not-zip-safe
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-0.20.post2.egg-info/requires.txt
-rw-r--r--  root/root   /usr/lib/python3/dist-packages/celery_haystack_ng-0.20.post2.egg-info/top_level.txt

No differences were encountered in the control files

More details

Full run details