"""The default loader used when no custom app has been initialized."""importosimportwarningsfromcelery.exceptionsimportNotConfiguredfromcelery.utils.collectionsimportDictAttributefromcelery.utils.serializationimportstrtoboolfrom.baseimportBaseLoader__all__=('Loader','DEFAULT_CONFIG_MODULE')DEFAULT_CONFIG_MODULE='celeryconfig'#: Warns if configuration file is missing if :envvar:`C_WNOCONF` is set.C_WNOCONF=strtobool(os.environ.get('C_WNOCONF',False))
[文档]classLoader(BaseLoader):"""The loader used by the default app."""
[文档]defread_configuration(self,fail_silently=True):"""Read configuration from :file:`celeryconfig.py`."""configname=os.environ.get('CELERY_CONFIG_MODULE',DEFAULT_CONFIG_MODULE)try:usercfg=self._import_config_module(configname)exceptImportError:ifnotfail_silently:raise# billiard sets this if forked using execvifC_WNOCONFandnotos.environ.get('FORKED_BY_MULTIPROCESSING'):warnings.warn(NotConfigured('No {module} module found! Please make sure it exists and ''is available to Python.'.format(module=configname)))returnself.setup_settings({})else:self.configured=Truereturnself.setup_settings(usercfg)