Beispiel #1
0
 def read_configuration(self):
     """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",
                                 DEFAULT_CONFIG_MODULE)
     try:
         self.find_module(configname)
     except NotAPackage:
         if configname.endswith('.py'):
             raise NotAPackage, NotAPackage(CONFIG_WITH_SUFFIX % {
                 "module": configname,
                 "suggest": configname[:-3]
             }), sys.exc_info()[2]
         raise NotAPackage, NotAPackage(
             CONFIG_INVALID_NAME %
             {"module": configname}), sys.exc_info()[2]
     except ImportError:
         warnings.warn(
             NotConfigured(
                 "No %r module found! Please make sure it exists and "
                 "is available to Python." % (configname, )))
         return self.setup_settings({})
     else:
         celeryconfig = self.import_from_cwd(configname)
         usercfg = dict((key, getattr(celeryconfig, key))
                        for key in dir(celeryconfig)
                        if self.wanted_module_item(key))
         self.configured = True
         return self.setup_settings(usercfg)
 def read_configuration(self):
     """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',
                                  DEFAULT_CONFIG_MODULE)
     try:
         self.find_module(configname)
     except NotAPackage:
         if configname.endswith('.py'):
             raise NotAPackage, NotAPackage(
                     CONFIG_WITH_SUFFIX % {
                         'module': configname,
                         'suggest': configname[:-3]}), sys.exc_info()[2]
         raise NotAPackage, NotAPackage(
                 CONFIG_INVALID_NAME % {
                     'module': configname}), sys.exc_info()[2]
     except ImportError:
         # billiard sets this if forked using execv
         if C_WNOCONF and not os.environ.get('FORKED_BY_MULTIPROCESSING'):
             warnings.warn(NotConfigured(
                 'No %r module found! Please make sure it exists and '
                 'is available to Python.' % (configname, )))
         return self.setup_settings({})
     else:
         celeryconfig = self.import_from_cwd(configname)
         usercfg = dict((key, getattr(celeryconfig, key))
                         for key in dir(celeryconfig)
                             if self.wanted_module_item(key))
         self.configured = True
         return self.setup_settings(usercfg)
Beispiel #3
0
 def test_reschedule_train_internal_celery_error(self):
     patched_method = 'openassessment.assessment.worker.training.train_classifiers.apply_async'
     with mock.patch(patched_method) as mock_train:
         mock_train.side_effect = NotConfigured("NotConfigured")
         with mock.patch(
                 'openassessment.assessment.worker.training.logger.exception'
         ) as mock_logger:
             with self.assertRaises(Exception):
                 ai_api.reschedule_unfinished_tasks(course_id=COURSE_ID,
                                                    item_id=ITEM_ID,
                                                    task_type=u"train")
             last_call = mock_logger.call_args[0][0]
             self.assertTrue(u"NotConfigured" in last_call)
Beispiel #4
0
 def read_configuration(self):
     """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',
                                 DEFAULT_CONFIG_MODULE)
     try:
         usercfg = self._import_config_module(configname)
     except ImportError:
         # billiard sets this if forked using execv
         if C_WNOCONF and not os.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)))
         return self.setup_settings({})
     else:
         self.configured = True
         return self.setup_settings(usercfg)
Beispiel #5
0
 def read_configuration(self):
     """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",
                                 DEFAULT_CONFIG_MODULE)
     try:
         celeryconfig = self.import_from_cwd(configname)
     except ImportError:
         warnings.warn(NotConfigured(
             "No %r module found! Please make sure it exists and "
             "is available to Python." % (configname, )))
         return self.setup_settings(DEFAULT_UNCONFIGURED_SETTINGS)
     else:
         usercfg = dict((key, getattr(celeryconfig, key))
                         for key in dir(celeryconfig)
                             if wanted_module_item(key))
         self.configured = True
         return self.setup_settings(usercfg)
 def read_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)
     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(
                     "No {module} module found! Please make sure it exists and "
                     "is available to Python.".format(module=configname)))
         return self.setup_settings({})
     else:
         self.configured = True
         return self.setup_settings(usercfg)