Explorar o código

DefaultLoader.read_configuration now supports fail_silently argument

Ask Solem %!s(int64=11) %!d(string=hai) anos
pai
achega
29a2204b03
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      celery/loaders/default.py

+ 3 - 1
celery/loaders/default.py

@@ -31,7 +31,7 @@ class Loader(BaseLoader):
     def setup_settings(self, settingsdict):
     def setup_settings(self, settingsdict):
         return DictAttribute(settingsdict)
         return DictAttribute(settingsdict)
 
 
-    def read_configuration(self):
+    def read_configuration(self, fail_silently=True):
         """Read configuration from :file:`celeryconfig.py` and configure
         """Read configuration from :file:`celeryconfig.py` and configure
         celery and Django so it can be used by regular Python."""
         celery and Django so it can be used by regular Python."""
         configname = os.environ.get('CELERY_CONFIG_MODULE',
         configname = os.environ.get('CELERY_CONFIG_MODULE',
@@ -39,6 +39,8 @@ class Loader(BaseLoader):
         try:
         try:
             usercfg = self._import_config_module(configname)
             usercfg = self._import_config_module(configname)
         except ImportError:
         except ImportError:
+            if not fail_silently:
+                raise
             # billiard sets this if forked using execv
             # billiard sets this if forked using execv
             if C_WNOCONF and not os.environ.get('FORKED_BY_MULTIPROCESSING'):
             if C_WNOCONF and not os.environ.get('FORKED_BY_MULTIPROCESSING'):
                 warnings.warn(NotConfigured(
                 warnings.warn(NotConfigured(