Changed celery config keys to upper case and removed upper casing of keys when initialising the config as per issue #214

This commit is contained in:
Luke Slater 2012-02-28 16:40:37 +00:00
parent baae1578da
commit 6bcdd4dc70
2 changed files with 41 additions and 96 deletions

View File

@ -80,53 +80,53 @@ lock_dir = string(default="%(here)s/user_dev/beaker/cache/lock")
[celery]
# default result stuff
celery_result_backend = string(default="database")
celery_result_dburi = string(default="sqlite:///%(here)s/celery.db")
CELERY_RESULT_BACKEND = string(default="database")
CELERY_RESULT_DBURI = string(default="sqlite:///%(here)s/celery.db")
# default kombu stuff
broker_transport = string(default="sqlalchemy")
broker_host = string(default="sqlite:///%(here)s/kombu.db")
BROKER_TRANSPORT = string(default="sqlalchemy")
BROKER_HOST = string(default="sqlite:///%(here)s/kombu.db")
# known booleans
celery_result_persistent = boolean()
celery_create_missing_queues = boolean()
broker_use_ssl = boolean()
broker_connection_retry = boolean()
celery_always_eager = boolean()
celery_eager_propagates_exceptions = boolean()
celery_ignore_result = boolean()
celery_track_started = boolean()
celery_disable_rate_limits = boolean()
celery_acks_late = boolean()
celery_store_errors_even_if_ignored = boolean()
celery_send_task_error_emails = boolean()
celery_send_events = boolean()
celery_send_task_sent_event = boolean()
celeryd_log_color = boolean()
celery_redirect_stdouts = boolean()
CELERY_RESULT_PERSISTENT = boolean()
CELERY_CREATE_MISSING_QUEUES = boolean()
BROKER_USE_SSL = boolean()
BROKER_CONNECTION_RETRY = boolean()
CELERY_ALWAYS_EAGER = boolean()
CELERY_EAGER_PROPAGATES_EXCEPTIONS = boolean()
CELERY_IGNORE_RESULT = boolean()
CELERY_TRACK_STARTED = boolean()
CELERY_DISABLE_RATE_LIMITS = boolean()
CELERY_ACKS_LATE = boolean()
CELERY_STORE_ERRORS_EVEN_IF_IGNORED = boolean()
CELERY_SEND_TASK_ERROR_EMAILS = boolean()
CELERY_SEND_EVENTS = boolean()
CELERY_SEND_TASK_SENT_EVENT = boolean()
CELERYD_LOG_COLOR = boolean()
CELERY_REDIRECT_STDOUTS = boolean()
# known ints
celeryd_concurrency = integer()
celeryd_prefetch_multiplier = integer()
celery_amqp_task_result_expires = integer()
celery_amqp_task_result_connection_max = integer()
redis_port = integer()
redis_db = integer()
broker_port = integer()
broker_connection_timeout = integer()
celery_broker_connection_max_retries = integer()
celery_task_result_expires = integer()
celery_max_cached_results = integer()
celery_default_rate_limit = integer()
celeryd_max_tasks_per_child = integer()
celeryd_task_time_limit = integer()
celeryd_task_soft_time_limit = integer()
mail_port = integer()
celerybeat_max_loop_interval = integer()
CELERYD_CONCURRENCY = integer()
CELERYD_PREFETCH_MULTIPLIER = integer()
CELERY_AMQP_TASK_RESULT_EXPIRES = integer()
CELERY_AMQP_TASK_RESULT_CONNECTION_MAX = integer()
REDIS_PORT = integer()
REDIS_DB = integer()
BROKER_PORT = integer()
BROKER_CONNECTION_TIMEOUT = integer()
CELERY_BROKER_CONNECTION_MAX_RETRIES = integer()
CELERY_TASK_RESULT_EXPIRES = integer()
CELERY_MAX_CACHED_RESULTS = integer()
CELERY_DEFAULT_RATE_LIMIT = integer()
CELERYD_MAX_TASKS_PER_CHILD = integer()
CELERYD_TASK_TIME_LIMIT = integer()
CELERYD_TASK_SOFT_TIME_LIMIT = integer()
MAIL_PORT = integer()
CELERYBEAT_MAX_LOOP_INTERVAL = integer()
# known floats
celeryd_eta_scheduler_precision = float()
CELERYD_ETA_SCHEDULER_PRECISION = float()
# known lists
celery_routes = string_list()
celery_imports = string_list()
CELERY_ROUTES = string_list()
CELERY_IMPORTS = string_list()

View File

@ -14,59 +14,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
MANDATORY_CELERY_IMPORTS = ['mediagoblin.processing']
DEFAULT_SETTINGS_MODULE = 'mediagoblin.init.celery.dummy_settings_module'
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
"""
if 'celery' in global_config:
celery_conf = global_config['celery']
else:
celery_conf = {}
celery_settings = {}
# Add all celery settings from config
for key, value in celery_conf.iteritems():
key = key.upper()
celery_settings[key] = value
# TODO: use default result stuff here if it exists
# add mandatory celery imports
celery_imports = celery_settings.setdefault('CELERY_IMPORTS', [])
celery_imports.extend(MANDATORY_CELERY_IMPORTS)
if force_celery_always_eager:
celery_settings['CELERY_ALWAYS_EAGER'] = True
celery_settings['CELERY_EAGER_PROPAGATES_EXCEPTIONS'] = True
__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
from mediagoblin._version import __version__