def setUp(self): backend = getattr(settings, 'CELERY_QUEUES_ONCE_CACHE_BACKEND', 'default') self.cache = get_cache(backend) try: self.cache.delete_pattern('queuedtasks:*') except AttributeError: self.cache.clear() current_app.config_from_object(settings)
def configure(filename='conf/pyvac.yaml', init_celery=True, default_app=None): with open(filename) as fdesc: conf = yaml.load(fdesc, YAMLLoader) if conf.get('logging'): dictConfig(conf.get('logging')) if init_celery: if not default_app: try: from celery import current_app as default_app except ImportError: # pragma: no cover from celery.app import default_app default_app.config_from_object(conf.get('celeryconfig')) # XXX: must call loader for celery to register all the tasks default_app.loader.import_default_modules() return conf
def setup_celery_from_config(app_config, global_config, settings_module=DEFAULT_SETTINGS_MODULE, force_celery_always_eager=False, set_environ=True): """ Take a mediagoblin app config and try to set up a celery settings module from this. Args: - app_config: the application config section - global_config: the entire ConfigObj loaded config, all sections - settings_module: the module to populate, as a string - force_celery_always_eager: whether or not to force celery into always eager mode; good for development and small installs - set_environ: if set, this will CELERY_CONFIG_MODULE to the settings_module """ celery_settings = get_celery_settings_dict(app_config, global_config, force_celery_always_eager) __import__(settings_module) this_module = sys.modules[settings_module] for key, value in celery_settings.iteritems(): setattr(this_module, key, value) if set_environ: os.environ['CELERY_CONFIG_MODULE'] = settings_module # Replace the default celery.current_app.conf if celery has already been # initiated from celery import current_app _log.info('Setting celery configuration from object "{0}"'.format( settings_module)) current_app.config_from_object(this_module) _log.debug('Celery broker host: {0}'.format( current_app.conf['BROKER_HOST']))
def setup_celery_from_config(app_config, global_config, settings_module=DEFAULT_SETTINGS_MODULE, force_celery_always_eager=False, set_environ=True): """ Take a mediagoblin app config and try to set up a celery settings module from this. Args: - app_config: the application config section - global_config: the entire ConfigObj loaded config, all sections - settings_module: the module to populate, as a string - force_celery_always_eager: whether or not to force celery into always eager mode; good for development and small installs - set_environ: if set, this will CELERY_CONFIG_MODULE to the settings_module """ celery_settings = get_celery_settings_dict( app_config, global_config, force_celery_always_eager) __import__(settings_module) this_module = sys.modules[settings_module] for key, value in six.iteritems(celery_settings): setattr(this_module, key, value) if set_environ: os.environ['CELERY_CONFIG_MODULE'] = settings_module # Replace the default celery.current_app.conf if celery has already been # initiated from celery import current_app _log.info('Setting celery configuration from object "{0}"'.format( settings_module)) current_app.config_from_object(this_module) _log.debug('Celery broker host: {0}'.format(current_app.conf['BROKER_HOST']))
def setup_class(self): redis.flushdb() current_app.config_from_object(settings)
def runtests(): parent = dirname(abspath(__file__)) #sys.path.insert(0, parent) current_app.config_from_object(TestConf) return defaultTestLoader.discover(parent)