Browse Source

DefaultLoader.read_configuration now supports fail_silently argument

Ask Solem 11 năm trước cách đây
mục cha
commit
29a2204b03
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  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):
         return DictAttribute(settingsdict)
 
-    def read_configuration(self):
+    def read_configuration(self, fail_silently=True):
         """Read configuration from :file:`celeryconfig.py` and configure
         celery and Django so it can be used by regular Python."""
         configname = os.environ.get('CELERY_CONFIG_MODULE',
@@ -39,6 +39,8 @@ class Loader(BaseLoader):
         try:
             usercfg = self._import_config_module(configname)
         except ImportError:
+            if not fail_silently:
+                raise
             # billiard sets this if forked using execv
             if C_WNOCONF and not os.environ.get('FORKED_BY_MULTIPROCESSING'):
                 warnings.warn(NotConfigured(