Browse Source

Also load CELERY_IMPORTS when running with django (as documented)

Ask Solem 15 years ago
parent
commit
243b29e729
3 changed files with 9 additions and 3 deletions
  1. 7 0
      celery/loaders/base.py
  2. 1 3
      celery/loaders/default.py
  3. 1 0
      celery/loaders/djangoapp.py

+ 7 - 0
celery/loaders/base.py

@@ -26,6 +26,13 @@ class BaseLoader(object):
         """This method is called when the worker (``celeryd``) starts."""
         pass
 
+    def import_task_module(self, module):
+        __import__(module, [], [], [''])
+
+    def import_default_modules(self):
+        imports = getattr(self.conf, "CELERY_IMPORTS", [])
+        map(self.import_task_module, imports)
+
     @property
     def conf(self):
         """Loader configuration."""

+ 1 - 3
celery/loaders/default.py

@@ -53,6 +53,4 @@ class Loader(BaseLoader):
         setting in ``celeryconf.py``.
 
         """
-        imports = getattr(self.conf, "CELERY_IMPORTS", [])
-        for module in imports:
-            __import__(module, [], [], [''])
+        self.import_default_modules()

+ 1 - 0
celery/loaders/djangoapp.py

@@ -45,5 +45,6 @@ class Loader(BaseLoader):
         ``INSTALLED_APPS``.
 
         """
+        self.import_default_modules()
         from celery.discovery import autodiscover
         autodiscover()